|
OceanWater
The ocean water shader aims at producing the effect of rolling deep-sea waves, as well as maintaining the reflective quality of a water surface. I originally wrote the effect for a small project, a 3D pirate game not unlike Sid Meier's "Pirates!. The project was never finished, but I kept the shader and intend to use it in the next ocean-based game i decide to make.
Using a simple grid mesh, the technique works through the use of the Simple Harmonic Motion equation. By summing a number of sinusoid's together, we can create a convincing "wave" surface across the mesh. The phase of each sinusoid is then increased over time to create the effect of animated rolling waves. By using different rates for each sinusod, complex constructive interference patterns can be created, producing very realistic wave motion.
Finally, the reflective properties of the water are implemented by interpolating the vertex normals across the visiable mesh. From this, the reflected eye normal is used to sample the appropiate texel from the skybox's cubemap. The main problem with this is that it ignores dynamic objects in the scene. However, I intend to improve this through in the future using the more traditional projective texturing reflection techniques.
The shader was written using GLSL, and can be viewed thorugh ATI's RenderMonkey.
GLSL Ocean Shader - RenderMonkey Package | Vertex Shader | Fragment Shader
|