title: How do I generate random points in 3D space?
body: <p>The biggest problem I am having is that I do not have the vocabulary to describe what I am after so if nothing else, some help with that would be much appreciated.</p>
  
  <p>From what I understand, Perlin noise can give you a random value for a point in 3D space and in addition any nearby points will have values that are similar. I have this working in a program to generate 3D blobs floating in space when the random value passes a certain threshold. This works well because I can pick any point, and without worrying about what points were calculated before, determine its value (could thread the blob generation if I wanted).</p>
  
  <p>I now want to do something similar except, I want to change the color of that point on the blob if the random value passes a certain threshold. However I want this to be random and unrelated to its neighbors (unlike Perlin noise). </p>
  
  <p>What kind of algorithm am I looking for to accomplish this?</p>
  
  <p>The key criteria: </p>
  
  <ol>
  <li>The function takes a 3D vector as a parameter.</li>
  <li>The values are totally unrelated from point to point. </li>
  <li>The order examining points does not affect the results of the function.</li>
  <li>The function returns the same result if the same point is passed to it.</li>
  </ol>
  
  <p><strong>Outcome</strong></p>
  
  <p>So I decided to use an approach similar to the answer by Kahler with some very small tweaks. I didn't want to use all the redirection and operations used by repeatedly instantiating or even just repeatedly seeding a random number generator. I ended up copying the random number generator used in the UE4 RandomStream class and making it fit my needs. I'm sure this generator is not theirs alone, as the numbers used seem to appear in other places, but that is where I found it.</p>
  
  <pre><code>float WhiteNoise::GetNoise3D(const FVector&amp; vector) const
  {
      int32 s1 = seed;
      int32 s2 = ((s1 + FMath::TruncToInt(vector.X)) * 196314165) + 907633515;
      int32 s3 = ((s2 + FMath::TruncToInt(vector.Y)) * 196314165) + 907633515;
      int32 s4 = ((s3 + FMath::TruncToInt(vector.Z)) * 196314165) + 907633515;
  
      const float tmp = 1.0f;
  
      float result;
  
      *(int32*)&amp;result = (*(int32*)&amp;tmp &amp; 0xff800000) | (s4 &amp; 0x007fffff);
  
       return FMath::Fractional(result);
  }
  </code></pre>
  
  <p>There are some obvious issues with the above code. One being that the numbers are not very random and the other being the truncation causing a granularity issue. Both of those are totally acceptable in my situation so this works reasonably well.</p>