Lake Water Rendering - Specular Highlights Update

The original specular highlight rendering is based on a single function that is described on the water mathematics page (HERE). The generic idea is using a trigonometric function of the light-direction vector. If the distorted reflection is close enough to the light direction the highlights get visible.

Vector L points towards the light-source, V towards the viewer, N is the normal-vector of the surface, R is the direction of reflection while H halves the angle between L and V.

If ß is the angle between N and H, the basic function looks like this:

(1)
\begin{align} k_{spec} \times cos^{n}(\beta ) \end{align}

, but this value can be calculated using the vectors and their dot product as well:
(2)
\begin{align} k_{spec} \times ( V \cdot N )^{n} \end{align}

In the HLSL code it looks something like this
float alpha= pow( dot(halfVector,normalVector), specPower);


Pretty simple, isn't it? The first problem, that this solution handles every direction in the same way and causes this specular highlight (still not using distortion):

If we apply some distortion, this can look more-or-less convincing, but we want something better. If we modify the Z value of the vectors before the same calculations we can adjust the shape of the highlight. What happens is we divide the Z values by 10? The same trigonometric functions will result an elliptic-shaped specular highlight, whose longer diagonal is 10 times longer than the shortest one, and that longer diagonal is always pointing towards the sun.

page revision: 6, last edited: 17 Nov 2009 19:45