Submitted by , posted on 30 October 2004

Image Description, by

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



Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.