Solid semi-transparency under water? Fog?

Started by zathras, October 10, 2009, 14:07:19

Previous topic - Next topic

zathras

Hi, I'm using LWJGL via the jMonkeyEngine, and I have a general question about fog and similar effects.

I'd like to create a scene with an above water and an under water part. But when the camera goes below the water surface (a flat quad), you cannot tell you're under water -- Obviously, I need to (at least) give the water-filled area a water-colored tinge? SecondLife for example has a similar effect  (I'm not even considering caustics here.)

Blue fog has the effect I need, a solid semi-transparent fill color with a fade. But fog covers the whole scene, also above the water surface... There is no way to clip fog at a certain y, is there? Or if I could have two fogs, one darkblue below, and one sky-colored above?

I don't know whether this question makes sense since I don't know how it's implemented. The jMonkeyEngine only uses the API given by LWJGL, as far as I understand, so they don't know either. If anyone has experience with this, please share a tip.  :)

bobjob

you may want to look into the stencil buffer.

there is a good example in the Nehe tutorials about the stencil buffer.

in the tutorial it gives an example of reflecions on the ground level.

but you could use it for fog under the water level.

zathras

bobjob, thanks for the tip, I'll have a look at the StencilBuffer, I assuem you mean this:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=26
It's not clear to me yet how it works. I'll report back if I figure it out.

bobjob

the LWJGL source code is at the bottom of that page.