Hello Guest

Solid semi-transparency under water? Fog?

  • 3 Replies
  • 6310 Views
Solid semi-transparency under water? Fog?
« on: October 10, 2009, 14:07:19 »
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.  :)

*

Offline bobjob

  • ****
  • 394
  • LWJGL: WOW SO GOOD
Re: Solid semi-transparency under water? Fog?
« Reply #1 on: October 10, 2009, 16:28:22 »
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.

Re: Solid semi-transparency under water? Fog?
« Reply #2 on: October 10, 2009, 16:57:17 »
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.

*

Offline bobjob

  • ****
  • 394
  • LWJGL: WOW SO GOOD
Re: Solid semi-transparency under water? Fog?
« Reply #3 on: October 10, 2009, 17:11:26 »
the LWJGL source code is at the bottom of that page.