Specular highlights

Posted on April 18, 2008. Filed under: Lake water shader, shader, Technical background | Tags: , , , , , , , |

Specular highlights

Specular highlights are approximated by adding some light color to specific areas as the Phong illumination model describes. For computational reasons, the half-vector is used instead of the vector of reflectance, for more details, see the Water mathematics chapter. The half-vector is also approximated, and some perturbations are added from the values of the bump-map (specPerturb). In this demo, I used the following code for this:

float4 speccolor;
float3 lightSourceDir = normalize(float3(0.1f,0.6f,0.5f));
float3 halfvec = normalize(eyeVector+lightSourceDir+float3(perturbation.x*specPerturb,perturbation.y*specPerturb,0));

The angle between the surface-normal and the half-vector is calculated using the dot product between them. An input variable (specpower) adjusts the power, which results the specular highlights only in case of a very little angle between the vectors. Finally, the specular color is added to the original one.

float3 temp = 0;
temp.x = pow(dot(halfvec,normalVector),specPower);
speccolor = float4(0.98,0.97,0.7,0.6);
speccolor = speccolor*temp.x;
speccolor = float4(speccolor.x*speccolor.w,speccolor.y*speccolor.w,speccolor.z*speccolor.w,0);
Output.Color = Output.Color + speccolor;

Some screenshots of lake water specular highlights:

screenshot_specular_4

screenshot_specular_2 screenshot_specular_3 screenshot_specular_4

Advertisements

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

One Response to “Specular highlights”

RSS Feed for Habib's Water Shaders Comments RSS Feed

This method is nice for water because it creates an anisotropy with the angle of incidence.
But a normal specular calculated with the reflect intrinsic would produce a correct circle whatever the incidence. to find the elongated specular again it would be necessary to take occlusion and shadowing in account which is too computationally expensive in real time. (can be done with special hardware like larabee)


Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: