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 u开发者_如何学运维p 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?
I believe the approach is to actually use a 3 dimensional noise field (every point in a 3D space has a scalar noise value) as opposed to a 2 dimensional field (every point on a 2D plane has a noise value).
When using a 2D noise function to generate a height map, you offset the z value according to the noise value.
When using a 3D field, you sample the noise at points on the surface of a sphere, then use the noise value to offset each point radially away from or towards the center of the sphere.
3D noise is harder and slower to produce obviously, but you don't have to deal with the complications of wrapping a surface around the sphere, and because the noise function is continuous there are no seams.
This can obviously be applied to any arbitrary shape.
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.
精彩评论