Hi,
I’m trying to add a simple specular effect to the water in a terrain model, and I’m experiencing some very strange artifacts. The following pictures show the effect.
http://www.worldbeside.com/screenshots/bug1.png
http://www.worldbeside.com/screenshots/bug2.png
As you can see it looks OK from a distance, but when zooming in, I get a shimmering sort of moire pattern in the specular highlight.
Here is the part of the fragment shader that calculates the specular. I’ve tried disabling everything else in the shader, and I’m pretty sure the problem lies in this code block somewhere:
color.r = 49.0/255.0;
color.g = 57.0/255.0;
color.b = 82.0/255.0;
vec3 ray = x0 - CameraPos;
vec3 v = normalize(ray);
vec3 n = normalize(x0);
vec3 h = normalize(LightPos - v);
float fresnel = 0.02 + 0.98 * pow(1.0 - dot(-v, h), 5.0);
float waterBrdf = fresnel * pow(max(dot(h, n), 0.0), 150.0);
vec3 sunLight = vec3(1.0, 1.0, 1.0);
color += max(waterBrdf, 0.0) * sunLight * ISun;
Here x0 is the untransformed vertex position in geocentric xyz-coordinates, LightPos and CameraPos are given as uniforms in world coordinates. LightPos is normalized and directed towards the sun. ISun is a constant = 30.
I’m running this in Ubuntu linux 9.04 on a Dell XPS m1730 with 2x NVIDIA 8700M GT’s in SLI. Driver version 180.44 (linux).
Any ideas?
Cheers