Rendering Water as a Post-process Effect
Possible improvementsOne of these add-ons that you can get with a small amount of work and yet which significantly improves the realism of the water effect is foam. It arises when the water hits the shore and at the tops of more choppy waves.The first of them, i.e. coastal foam, can be obtained by making an assumption that foam begins at the edge (that is, at the depth equal to 0), and to a certain depth H1 remains constant, and in the range extincts completely. Whereas the latter can be achieved by using the following formula:
where:
Another possible extension is to add the interaction between world objects and water. The basic form of interaction will be provided if you use foam as described above. Since it is closely related to the depth at the point of the water area, it will appear wherever the depth is small. As a result it will appear whenever an object falls into the water. However, the possibilities of interaction between water and the rest of the scene are literally unlimited. By modifying height-map either on CPU or in pixel shader you can easily introduce local disturbance for instance.
Disadvantages of the presented techniqueAlthough the presented technique removes most of the defects of existing water rendering techniques listed in the section “Traditional approaches to water rendering” there is still enough room for improvements due to several drawbacks of the current algorithm:
Final results and summary![]() Image 4 You can achieve many different kinds of water using the presented technique, from tropical warm seas to cold lakes. The algorithm presented in this paper is a good alternative to the popular techniques used for rendering water effects. By using calculations based on the observation of the phenomenon, rather than on existing mathematical models, I have managed to achieve a realistic effect, which in the case of properly selected parameters’ values makes it possible to achieve results comparable with much more expensive models. It is also a flexible solution - the appearance of water can be controlled through a number of attributes. This makes it suitable for a wide range of effects no matter it be lakes or oceans. You can even have several areas of radically different waters at the very same time. Besides, as it does not rely on geometry it eliminates the most common flaws of the popular techniques discussed in more detail in the section “Traditional approaches to water rendering” of this article. A word on implementationThe provided shader has been implemented using HLSL and DirectX 9. At present it requires a SM 3.0 capable GPU to run, however, it can be heavily optimized as my main concern was to make it as readable and simple as possible.Several textures are used in the code:
As water is rendered as a post-process effect, a full-screen quad has to be rendered on the screen with the water shader applied. Further reading[1] Toman W., "Deferred shading as an effective lighting technique”, IGK’2008[2] Placeres F. P., “Fast Per-Pixel Lightning with Many Lights”, “Game Programming Gems 6”, Charles River Media, 2006, Boston [3] Hargreaves S., “Deferred Shading”, GDC, 2004, available on-line [4] Guillot B., “A reappraisal of what we have learnt during three decades of computer simulations on water” [5] Jensen L. S., Golias R., "Deep-Water Animation and Rendering“, available on-line [6] Johanson C., "Real-time water rendering - projected grid concept”, available on-line [7] Kryachko Y. "Using Vertex Texture Displacement for Realistic Water Rendering”, GPU Gems 2 [8] Schuler C., “Normal mapping without precomputed tangents”, ShaderX 5 |
|