Search code examples
randomnoise

Coherent Spherical Noise?


Does anyone know how I might be able to generate the following kind of noise?

  • Three inputs, three outputs
  • The outputs must always result in a vector of the same magnitude
  • If it receives the same input as some other time, it must return the same output
  • It must be continuous (best if it appears smooth, like perlin noise)
  • It must appear to be fairly random

EDIT: It would also be nice if it were isotropic, but that's not entirely necessary.


Solution

  • I've found a way, and it might not be very fast, but it does the job (this is c-like pseudocode designed to make porting to other languages easy).

    vec3 sphereNoise(vec3 input, float radius)
    {
        vec3 result;
        result.x = simplex(input.x, input.y); //could use perlin instead of simplex
        result.y = simplex(input.y, input.z); //but I prefer simplex for its speed
        result.z = simplex(input.z, input.x); //and its lack of directional artifacts
    
        //uncomment the following line to make it a spherical-shell noise
        //result.normalize();
        result *= radius;
        return result;
    }