I'm working on tweaking our water shader to get a nicer look out of it and there are a couple of issues I'm not sure how to solve. The main one is that the colorization, while nice during the day, makes the water look lit up at night and is very unnatural:
[attachment=15824:RuinValor 2013-05-19 20-57-37-99.png]
All I'm doing is lerping between the sampled refraction color and a water color parameter. How can I make it so it isn't "creating light"?
Another issue I'm having is the specular. Works during the day, creates black spots at night. Running through the shader debugger, I found it was returning QNANs, but I can't understand why, I have an if-statement that should return 0 specular for when the dot product returns a negative:
float specular = dot(normalize(reflectionVector), -eyeVector);
float3 specColor = 0;
if(specular > 0)
{
specular = pow(specular, SpecPower) * 5;
if(specular > 0) //This doesnt help either
specColor = normalize(SpecColor.rgb) * specular;
}
One last issue I'm working on is making the water color strength vary based on the depth of the water. I haven't been able to find any documentation online about this so I've just sort of been making something up and playing around with it to see what works well. What I've done so far is read the terrain depth buffer sampled straight along the view ray, subtracted the depth from the camera to the surface, and then used that in an exponential fog equation. It works pretty well but seems a bit strange when shallow water becomes very foggy when viewed at a shallow angle. Any advice for this?