Water specular highlights

I’m tweaking a water shader and one of the things that still look wrong are specular highlights. At some angles it looks ok:

But after rotating the camera a bit the shiny patches disappear:

I’m using a directional light and I get the specular highlights with this code:

   float4 lhalf = dlight_dlight0_rel_view[3];
   float4 lcolor=dlight_dlight0_rel_view[0];
   float shine=500;   
   float4 specular = pow(saturate(dot(l_eye_normal.xyz, lhalf.xyz)), shine);

Anyone knows a better way to do it?

How is l_eye_normal calculated – does it take the normal map into account?

Off the top of my head, it’s not obvious what the issue might be. The shininess exponent looks awfully high, but I don’t know if that is the problem here. Also try and see if normalizing the vectors before passing them to dot() fixes anything, in case one of the vectors is not normalized.

I do know that some lighting models don’t perform very well at grazing angles, this is something you should consider when deciding on a particular BRDF.

I was thinking I did normalize the (surface) normal vector but I did it in the wrong place :blush:
I’ve got 2 normal maps (ok, 1 map sampled twice), scrolling in different directions at different scales, I added them together and normalized them. At least that was what I was hoping to do… in reality I added them, translated them to view space and then normalized them, where I should normalize them after adding.

The exponent is very high, I know, but at lower values my water plane turns almost white - but I did lower it a bit (to 350 :unamused: ).

Now there are at least some highlights and I’d call that good enough.

When adding vectors, you should normalize them both before and after. But the input vectors should (ideally) be already normalized.