"Government is like a baby. An alimentary canal with a big appetite at one end and no sense of responsibility at the other."
- Ronald Reagan

Framework 4 (Last updated: October 25, 2019)
Framework 3 (Last updated: February 6, 2017)
Framework 2 (Last updated: October 8, 2006)
Framework (Last updated: October 8, 2006)
Libraries (Last updated: September 16, 2004)
Really old framework (Last updated: September 16, 2004)
Water
Thursday, November 20, 2003 | Permalink

Executable
Source code
Water.zip (697 KB)

Required:
Vertex shader 1.1
Pixel shader 2.0
RGBA16 render targets
This demo generates waves on a water surface purely on the GPU. A number of "drops" every second disturbs the surface and a shader takes care of handling the water physics. It is handled through a spring field that is iterated and bumped between two render targets. The spring field contains height and velocity for each pixel on the render target. The drops are created by occasionally throwing in a tiny circle at some random spot on the render target. Another shader then extracts the water normals from the current spring field by applying a sobel filter on the heights. Using this normal a reflection and refraction vector is computed, which is then used mapped into a cubemap for reflection and refraction on the water surface. While the scene of this demo is simple in its arrangement, I would say that the results are pretty good, and this technique can very well be used in more complex scenes.

It should run on Radeon 9500 and up.

2003-11-28:
Updated to support user created waves. Just right-click and move the mouse pointer across the surface. I also added a menu option to turn auto-dripping off.

2003-12-08:
Updated to use fixed point render targets instead. The advantage of this is that we get filtering, which can be used to evaluate the sobel filter in a quicker way.