Search code examples
algorithmlanguage-agnosticperlin-noise

How can I generate Perlin noise on a spherical surface?


I am trying to generate terrain using Perlin noise. I understand how to generate it using Cartesian coordinates, but can't quite wrap my head around how it would work on a sphere. I know that you can project 2D surfaces onto spheres, but wouldn't the distortion mess up the noise distribution? The best idea I can come up with for generating uniform noise on the surface of a sphere is to map the point on the sphere to a 3D Cartesian coordinate and use a 3D noise function. (Basically, to generate a cube of noise and "shave away" the corners to make it round, as it were.) Is there a better method I'm missing?


Solution

  • The real puzzle here is how to alter the Perlin noise basis functions (called octaves?), which are defined using frequency and amplitude so that they are over a sphere instead of an n-dimensional plane.

    So, we need to have a set of basis functions (given direction, frequency, and amplitude) defined over the sphere. Direction is a point with, say, zero value. For any point on the sphere, you measure the angular distance to the direction vector. You divide the angular distance by the frequency, and calculate the sin of that angle. Finally, you scale by the amplitude.

    You can do something a little fancier if you want your basis functions to vary differently in two-dimensions, but you will need a second direction parameter to orient the projection. You will also need to calculate two angular distances. It might be overkill though. If you have a bunch of basis functions, the circular patterns of the algorithm above might completely blur each other out, so I would try the easy solution first.

    Using these Perlin noise basis functions, you can now evaluate your Perlin noise over the sphere as the sum of a bunch of these. Whether you decide to tesselate the sphere and evaluate the vertex corners is up to you. That's what I'd do.