Volumetric Clouds

So it’s been about a month…which means I’ve been super busy. The latest project I’ve gotten myself into has been learning about volumetric clouds. And wow has it been a lot of learning! I can’t say that I completely understand everything that I’ve delved into concerning this topic, but I’ll try to explain it all as best I can.

So what exactly does volumetric mean? Simply put, it refers to objects that have volume, that is to say they can be measured. Contrary to other popular ways which are much more CPU-friendly, such as billboarded clouds, volumetric clouds are meant to be truly 3-dimensional, and therefore, much more realistic.

Marching Cubes

I am sure there is more than one way to create volumetric clouds, the method that I am currently experimenting with is called Marching Cubes. Here is a great explanation, by Paul Bourke, that helped me to understand them. Basically, it is a way to visualize a set of 3d data (referred to as a scalar field). This data could be loaded in from a file or it could be generated on the fly by some arbitrary function that you define. Since no two clouds should be looking the same, the procedural approach, meaning generating in real-time, is the approach that will allow for the most variety. Of course, the challenge is to make the generating of the geometry fast enough to allow for interactive frame rates.

The following objects were made with various algorithms used to generate the scalar field values…such as a warped plane, a sphere, or just pure experimentation.

A cave!

A very strange spherical ?cloud?

And an igloo..

Perlin Noise

Yet another challenge to making nice fluffy clouds is coming up with a way to make them look nice and fluffy…or to just make them look like clouds AT ALL. Once I had my head wrapped around the concept of marching cubes, I still had no idea how to generate the proper cloud-worthy data (scalar field) that the marching cubes algorithm builds the geometry from. This is where noise comes in, and Perlin Noise is what I found to be a good place to start.

Eventually I added the concept of noise to my increasing wealth of knowledge, but I needed more…or rather, a different type of noise that would generate the fluffiness I sought. It was then that I stumbled upon a noise library, called libnoise, which I must say is very expansive in its noise-making capabilities. Since I had little motivation to mess around trying to derive exactly the right type of noise from mathematical equations, I found libnoise to be just the right thing. I am still experimenting with it, but I’ve had some more promising results this way.

2d texture applied to a plane

2d noise texture applied to a plane

The above image looks more like clouds, but it was only an experiment with noise textures, this one’s only 2-dimensional…and that’s easy…and lame ;) !

3 gluspheres with noise and alpha blending

3 gluspheres with noise and alpha blending

I broke away from marching cubes for a bit to try using just a regular sphere and then applying noise to it. It starts to look more convincing, but I’m just not feelin’ it. I think this route would be doable, but it doesn’t allow for the immense flexibility and control that marching cubes do.

A cube-shaped cloud created with marching cubes and billow noise

A cube-shaped cloud created with marching cubes and billow noise

This is the very last version I have created using marching cubes. It uses billow noise from the libnoise library and does some simple alpha blending in the pixel shader.

So that’s where my volumetric cloud project stands as of right now. I will be adding posts in the future as I gain (hopefully) progress towards more and more realistic volumetric clouds. Eventually, when I get to the point where I am able to organize the code all nice and pretty, I will put that up for anyone to tinker with.

Till next time!

About Ray Johannessen

Currently a Game Engineer at Tournament One in Stamford, CT. Love to play games, read, write, drum, program, watch movies, and chill with my wife & daughter.
This entry was posted in Programming and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>