Underwater Effects

Hi, this is my first post, so be gentle ;)  I'm an experienced Java programmer, but just getting into 3d graphics.  I've read most of the tutorials, wiki, lots of old posts, etc.  I'm working with JME2 out of SVN.



My eventual goal is to build a game where you are a fish living in a pond.  I want to model the outside (above water) environment enough that you can see it through the water surface from underneath, and briefly get above water by jumping, etc, but the visual focus will be on simulating a nice underwater environment, with caustics, godrays, plants, other fish, etc.



I'm just starting out and trying to modify the TestTerrain class so that when you drop below the water's surface, you get a different environment - much denser fog with a dark blue tint, etc, as if you really were underwater.  But I want you to still be able to see the terrain below (though obscured), as well as the transmitted image of the terrain above the water.



I'm having a hard time understanding how to achieve this effect.  I'm guessing I need two Nodes in the scene graph, one for all the above-water stuff, and one for all the below-water stuff, with different FogStates, etc.  Do I need to somehow split apart the parts of the terrain that are above water and below water, and put those in their respective nodes?  I figure if I try to reference the same terrain from both Nodes, I'll have problems with the boundaries overlapping.



Can anybody suggest a strategy for getting where I want?  Am I on the right track trying to hack on TestTerrain, or would I be better off trying a different way?

Maybe I cheated, but I ended up just switching the rootNode's FogState depending on whether the camera was above or below the water in simpleUpdate().  The effect is something like what I'm looking for, though the above-water scenery is affected by the below-water fog settings, and vice versa.



Any other suggestions, or hints at how I might better simulate an underwater environment?

i would have tried it the same way you did :slight_smile:



in games like everquest for example, the fogstate or blur effect changes exactly like you did it, s soon as the camera goes below the water line.

Sometimes you could cheat and see clearly underwater, if you found the right spot just below the water line.



Additionally to changing the fogstate, maybe you can add a shader effect which makes the picture blurry as soon as you go below the waterline.

Maybe pinning an animated quad in ortho mode over the entire screen ???

Maybe I cheated, but I ended up just switching the rootNode's FogState depending on whether the camera was above or below the water in simpleUpdate()
+

did the same in hhexen
mattias said:

Maybe I cheated

You can't cheat in game programming. If it works, it's valid and usable.

hhexen is a patchwork of cheats :wink: