Ocean opacity
I think you are looking for a Fresnel shader.
Here's a page about that and other water effects
I think you are looking for a Fresnel shader.
Here's a page about that and other water effects
Ohhhh so this is what Fresnel is !
I came accross this word as i was looking into other ocean shaders, but have not looked it up yet, thanks !!!
Fresnel term isn't really to do with water depth, it's to do with the angle you view the water at, it looks more reflective/opaque looking down at the water and more transparent the shallower the view angle. It looks pretty good though.
EDIT: I may have that the wrong way round though ;)
For the blue shift component of it, you're going to need to compute the ray from the vertex or pixel to the camera, then work out how far along that ray you hit the water surface. That distance value can be used to lerp between water color and object color. Fairly straightforward to do in a shader. Note that the correct approach is to subtract a mostly red color, rather than to interpolate towards a blue color.
Yeah it worked !
But it's still using blending states for the "transparency", so no refraction/reflection, caustic ect ...
Time to start working on that i guess.
Anyway, thanks a lot folks !
Oops, well, looks like this is solved already.
If somebody still wants to try the original concept in a cheap way but accounting for the angle, don't forget that one could always just use the depth buffer to retrieve the depth below the water without any extra calculations (just make sure the water renders after everything else). This could be used to create a fog-like effect.
The above trick assumes this is done in the pixel shader, but hey, it's a rather simple one :P Also would work for pretty much anything where you want to make a fog effect (in fact, water doing this is pretty much for the same reason fog happens in the air, so it's literally fog).
Yep, combining Fresnel with a fog like effect would be good too. Fresnel is really meant for controlling the reflectivity component I think. Adding a scrolling bump map for the water surface looks good too especially if you combine it with specular highlights from the sun/moon.