Register or Sign In
Forums - General Discussion - Single Pass Procedural Planet Rendering.

October 03, 2010 at 5:29:38 PM
Joined March 24, 2010
Last Online 3 years ago
Single Pass Procedural Planet Rendering.

So you want to render procedural planets? First you're going to need noise for the terrain. Second you're going to need to render the the actual sphere that makes up the planet and deform it with the noise. Lastly you're going to need to do this very fast. Well good news I have just the thing!

Single pass procedural planets may sound too good to be true but it's not. I have already tested most of what I'm about to discuss. At the time I had the idea I was limited by hardware and software but I was still able to test some of the major concepts.

Generating the noise is the first thing we are going to discuss. We will use a tiled 3D volume texture with trilinear filtering. If you have any idea what I'm talking about so far it will sound a little odd but it's probably the fastest way. You will fill the texture with random gray scale static sort of like the fuzz that a TV with bad reception gets but in a 3D cube. The trick is to read from the 3D volume texture based on the position of each vertex that make up the planet and then layer the distortion at increasingly higher resolutions for each layer. Don't understand what I'm talking about? This may help:

The black box is the 3D volume texture and the blue circle is the planet. Each red dot is one of the vertices that make up the planet. We want to sample from the 3D volume texture at each vertex then offset the vertex position radiating outward from the center of the planet.

Now you know why we are using a tiled 3D volume texture but you may not know why we are using trilinear filtering or even what it is. Basically it just smooths the noise from the texture. A one dimensional representation of a texture with no filtering, bilinear filtering, and trilinear filtering looks like this:

As you can see without filtering it does not look much like terrain and with bilinear filtering it's too shape but with trilinear filtering it looks just right.

Now that you understand why we are using trilinear filtering it's time to combine each layer. First you need to decrease the amount of effect each layer has proportionate to the texture resolution you used for that layer. For example:

Then when you add two layers together it would look something like this:

So that's how you generate the noise now we need to render the geometry in a single pass but there is no way to render all the polygons required for an entire planet so we will need to use some type of dynamic level of detail.

The easiest method would be to use a quad tree. A quad in this case is a mesh panel that's 17x17 or 33x33 or 65x65 vertices in diameter. The quad tree algorithm would check to see how close the camera is to the quad and if it is within a predefined range it will split the quad into four more quads.

To do this on the GPU in a single pass we will need to use the geometry shader to draw each quad and position it on the quad panel. After this you will create a cube out of the quad panels and normalize the vertices to make a sphere then apply the noise.

This article only covers the planet without any environmental effects but I am sure you can even include those into a single pass. In closing I hope this article was at least somewhat interesting to you and I hope you are able to put it to good use!