jMonkeyEngine 3.0 post process water

Anonymous Jan 24, 2011 at 09:00


jMonkeyEngine 3.0 is an open source java 3D engine based on OPENGL
This is a screenshot from its brand new post process water effect.

The effect was implemented from the original article from Wojciech Toman’s : Rendering Water as a Post-process Effect
The idea is to render a water plane in a post process rendering, on a full screen quad.
The scene is rendered in a frame buffer, and used as a texture on this quad.
In this article the author uses the effect in a deferred rendering process, taking advantage of the pre-rendered position buffer to retrieve the position in world space of any fragments.

jME3 default behavior is to use a forward rendering process, so there is no position buffer rendered that we can take advantage of. But while rendering the main scene to a frame buffer, we can write the hardware depth buffer to a texture, with nearly no additional cost, and then reconstruct the position of any fragment in the shader from it.

There is no geometry used for this effect, every pixel of the water plane is rendered in the shader by evaluating is position in world space and especially its height.

The waves are created based on a height map, and the normals are computed from it by fetching 4 near-by samples.
A normal map is used to create small ripples on the surface.
We have no geometry so, no tangents nor bi-tangents (aka bi-normals), we have to compute them on the fly. this is done by using a technique described by Schuler C. in Shader X 5, (Normal mapping without precomputed tangents)

The refraction color is computed via a clever color extinction algorithm, and distorted via a sinusoidal function.
The reflection and specular are computed in a standard way using the fresnel term.

In addition a foam texture is used and appear on the water surface depending on the water depth. Also the effect allow to blend the water edges with the shore to avoid the classic hard edged water plane.

This effect is highly configurable, and can achieve ocean water like in the screen shot above, but also muddy lake water like in this

You can see the effect in action in this video
You can visit us at or (community web site)

0 Replies

Please log in or register to post a reply.

No replies have been made yet.