I recently talked a lot with Sean O Neil (check out his website) and Lutz Justen (his website) about planet and clouds rendering. Lutz has some impressive satellite views of Earth, but he's just using textures - if you zoom at low altitudes, you will see it's only a flat layer of clouds. He does handle shadows of the clouds on the land though. I will use the same approach for space views, but i want the user to be able to come close to the clouds, and even fly through them if possible. My clouds must be volumetric.
Sean has already started an implementation of volumetric clouds - he's even got a demo you can download on his website -. They look good but he's still working on his planet-scale implementation.. i wish him good luck.
All these discussions about volumetric clouds made me want to give it a try myself. It was on my TODO list anyway, so i spent a few hours today to work on it. My current plan is in two steps:
1. Generating a 3D voxel grid that contains cloud densities and displaying it with particles.
2. Merging this technique with a global scale texture. I will probably assign a voxel grid (covering 1 km x 1 km in world space) to each texel in this texture. The texture itself will cover the whole Earth and will be of a high resolution.
More on step 2. in the next days.
As for step 1, i remembered a paper on vterrain.org i read a few years ago about clouds generation. It's called A Simple, Efficient Method for Realistic Animation of Clouds, by Y.Dobashi, K.Kaneda, H.Yamashita, T.Okita and T.Nishita. (Siggraph 2000). I am not quite sure yet if i will do the animation part, but to generate the clouds, this technique is extremely simple to understand and to implement. It's based on a cellular automate; each voxel contains 3 boolean states (humidity, transition phase and cloud presence) and the algorithm uses some transition rules to step the simulation. After a while, puff of smoke, forming clouds, appear. It's a matter of choosing the correct parameters and to be able to visualize the results.
There was a few tricks though. First, by reading the paper too quickly, i didn't realize the parameters probabilities weren't constant for all the voxels. The authors used some ellipsoids to fill each voxel with the probabilities. Since i jumped over this important detail initially, i ended up with a voxel grid filled with noise. Not very nice.
When i spotted the error, it immediately started to look better. I generated ellipsoids randomly over the grid, and the algorithm generated one cloud shape per ellipsoid. The next step was to evaluate the cloud densities in [0-1] by smoothing the voxels (which were still boolean before: there's clouds or there's no clouds), and then to shade the voxels. For shading i cast 16 random rays into the sky and collected the amount of light reaching the voxel.
The final step was to convert the voxel space into a set of particles. Each particle is given an alpha value for transparency which equals the cloud density at the voxel; its radius is constant, and its color is the shading value previously calculated. I then wrote a small viewer to sort the particles by squared distance to the viewer, and render each voxel particle with a cloudy texture.
I haven't optimized for performance yet - i need to optimize fillrate with the alpha test, bandwidth by using something more advanced than OpenGL's immediate mode, and play with the parameters and lighting. One important thing i must implement before switching to the planet scale rendering is impostors. I will not be able to render thousand of clouds, each cloud made of thousand of particles, in real time without impostors.