Not logged in, Join Here! or Log In Below:  
News Articles Search    

Submitted by Andres Reinot, posted on October 30, 2004

Image Description, by Andres Reinot

This is a cloud demo Jeff Russell and I (Andres Reinot) wrote over the weekend. It renders translucent clouds as sprites in openGL with ARB vertex and fragment programs.

Each sprite has a normal map and a transmissivity map, and the sprites are sorted and alpha blended.

The complete lighting equation involves doing a diffuse calculation with the surface of the cloud defined by a normalmap. To the diffuse term we add the illumination of the light transmitted through the cloud from any light sources behind it. This is approximated by the dot product of the eye and light vectors, and modulated by the transmissivity map of the sprite.

Illum = Transmissivity * ( -Eye . Light ) + diffuse

The diffuse term is calculated from a normal map in the standard per-pixel method.

We used wrap lighting for the transmissive term, which maps the values generated by the dot product from the range [-1,1] to [0,1]. This results in the hilight "wrapping" around edges to emulate subsurface scattering and helps the cloud look good when the light is at a 90 degree angle to the eye.

So the final equation with the scale and bias for the warp lighting ends up as:

Illum = Transmissivity * ( ( -Eye . Light ) * 0.5 + 0.5 ) + diffuse

Jeff Russell
Andres Reinot
with contributions from Bill Llib

Image of the Day Gallery


Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
Mirko Teran-Ravnikar

October 30, 2004, 03:03 AM

This looks interesting. Could we get a running demo? Or could you post some spec how fast it works or some more screenshots (with less red :)).

Alexander Stockinger

October 30, 2004, 05:11 AM

I must say that those are among the best clouds I ever saw rendered. They really look great. Still I'd be interested what kind of performance you get with that...



October 30, 2004, 06:28 AM

It looks good, although I think a shot of a more real life looking cloud would be much more helpful, for example a white cloud on a light blue background or gradient.

Daniel Talagrand

October 30, 2004, 08:47 AM

I agree, the cloud effect is one of the best ones I've seen (considering the actual parameters used). It would be great to have a demo featuring this effect. Personally, I'm definitely going to try this algo out =)


October 30, 2004, 09:05 AM

I too would like to see a live demo of this, the screenshot looks amazing.


October 31, 2004, 12:38 PM

We have posted a website and a downloadable demo here:

It should run on windows, osX, and linux (additional assembly required).
The source, makefile, and VC project files are also included.


October 31, 2004, 12:42 PM

We have posted a website and a downloadable demo here:

It should run on windows, osX, and linux (additional assembly required).
The source, makefile, and VC project files are also included.


October 31, 2004, 02:33 PM


Good to see a fellow from ISU, did you get to try it out in the cave? Also, have you tried using sprites with more white at the center? It seems out of whack when I see dark blotches in the center of the cloud.

Mirko Teran-Ravnikar

November 02, 2004, 02:09 PM

Thanks for posting a demo. With source even. The performance is a bit critical, but there is some room for improvement. The whole thing looks impressive in action except for popping...

Great work!

This thread contains 9 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.