I’m a new panda3d user and have put together a little project. Based on the documentation and samples from others, I have made pretty good progress. I have however not found a good way to create an underwater effect. In the project I would the vision of the screen to be clear while the camera is above water, but when the camera is below water I would like some type of water effect be applied. If the camera is halfway both in the water and out of the water I’d like effect to be place only below the water plane. This effect could be as simple as a fog which gets thicker. Now I see in the documentation that there are ways to do fog but they cannot seem to be only below the water plane. Any suggestions?
Fog is a scene graph attribute like anything else, so it can easily be applied only to the geometry below your water plane. It does mean you have to separate your scene into two discrete sets: everything above the water plane, and everything below it; and if there are things that cross the water plane, they will have to be divided right there.
If you can’t easily do this to your scene (for instance, because you have floating things that have to bob up and down), then you will have to render your scene twice, once with fog applied and once without, and use something like a stencil buffer to apply it only to the appropriate part of the scene. This is of course expensive, so you could cleverly do it only when the camera is intersecting the water plane.
Or, you could write a custom shader that would fog only the objects below the water plane, but this is even more complicated.
@CHWoithe did you ever develop a solution? I’m trying to accomplish the same thing.