Drops of Water and texture sprites

Sylvain Lefebvre

The Drop of Water shader is an animated effect showing drops falling allong a surface. The shader relies on a fragment program and therefore no geometry is required for the rendering of the drops: all is done in texture space. The two pictures on the left are only one geometric quad textured with the shader. The drop shape is encoded in a texture. The shader instanciates the drops in texture space where asked by the application. A transformation (scaling and rotation) can be applied on each drop. All happen like if drops were sprites drawn in the texture.

The rendering of drops is done using a faked refraction effect. The rendering of the underlying surface is done with the Phong model. The specular and diffuse coefficient are modulated by a texture to achieve a wet effect. This texture represents the wet areas. It is obtained by rendering the drops as white spots at each time step. The new state is blended with the old texture to accumulate wet areas.

Videos are available here.

The Drops of Water shader is part of the ShaderX2 - Tips and Tricks book. The source code is available on the CD-Rom.
An earlier version of the shader was released on www.cgshaders.org