Contact Info

Glowing Signs Shader

Glowing
Signs

Moving Cars Shader

Moving
Cars

12th Man Flag Shader

12th Man
Flag

Metal Shader

Corrugated
Metal

Wattle and Daub Shader
Tree Trunk Shader
Water Shader Rippling Water
Flame Shader Flickering Flame
Water Shader Step by step tutorial - 1 - 2 - 3 - 4

STEP 1: A Basic Sine Wave

The essence of a realistic water shader is the sine wave.

By layering sine waves of different sizes from different directions and then animating each one, a realistic rippling surface can be created.

 

 

wave_sample
/* displacement magnitude */
(float Km = 0.1,
/* number of waves in one uv tile */
macro_freq = 5,
/* offset to animate */
phase = 0.5,
string coordsys = "object";)
{
float hump = 0; normal n = normalize(N);
/* create the basic wave */
point p = transform(coordsys, P);
float wave_macro = getWave(s, macro_freq, phase, 0, p);
hump = wave_macro;
P = P - n * hump * Km; N = calculatenormal(P);
}

LIBRARY FUNCTION
float getWave(float angle, freq, phase, chop; point p)
{
return sin((angle + phase) * 2 * PI * freq);
}

  NEXT >