4 ms·
Author here. The water effect is a simple 2D heightfield simulation, which is explained pretty well at http://www.matthiasmueller.info/talks/GDC2008.pdf http://
by constexpr 13y ago
Author here. The water effect is a simple 2D heightfield simulation, which is explained pretty well at http://www.matthiasmueller.info/talks/GDC2008.pdf http://www.matthiasmueller.info/talks/GDC2008.pdf. It essentially just moves each vertex toward the average height of its neighbors, which turns out to propagate waves that look like water ripples.
The caustics are also pretty simple. Basically you take your heightfield mesh that represents the water surface and project each vertex independently along the ray refracted from the light through that vertex (using the vertex normal) and onto the pool floor. So you now have a mesh that is completely on the pool floor and contains lots of tiny triangles. To render caustics, just make triangles that got smaller brighter and ones that got bigger dimmer. I think I used the ratio of the projected area to the original resting area.
The reflection and refraction raytracing is all hard-coded for the geometry in the scene, which makes it really easy. It's just a simple sphere and box intersection test. The "ambient occlusion" is done by making parts of the objects darker when they get near each other.
State of the art for real-time water uses a full 3D volumetric representation for the water like in this paper: http://www.matthiasmueller.info/publications/tallcells.pdf http://www.matthiasmueller.info/publications/tallcells.pdf. This lets you get waves that can fold over themselves like real waves. I haven't seen any other realtime methods that have caustics as good as the ones in my demo though.
- Florin_Andrei 13y ago> It essentially just moves each vertex toward the average height of its neighbors, which turns out to propagate waves that look like water ripples. If you look at the equations that govern the liquid surface, the assumptions that this model is based on are not that bad. Reality is a bit more complex, but the average-of-neighbors seems like a good start. Pretty simple too, which is always good computationally. > The reflection and refraction raytracing is all hard-coded for the geometry in the scene, which makes it really easy. Which reminds me... Back in the days of 386 CPUs, I did a real-time 3D ray-tracer that drew a few spheres rotating around each other, with a fixed light source, and correct illumination depending on incidence angle at any point on the spheres. All on a 30 MHz 386 CPU, nothing pre-rendered, no assembly code, no GPU, running at high frame rate. Bricks where shat when people saw it. The reality was that the math was highly optimized for that specific scene. I massaged the equations until I worked out of them all the expensive functions. No sin() or cos(). I think the worst thing I had was a sqrt(), and even that was used sparingly. > The "ambient occlusion" is done by making parts of the objects darker when they get near each other. You're basically modelling Le Sage's theory of gravitation, with surface illumination representing "pressure" from the "corpuscles". http://en.wikipedia.org/wiki/Le_Sage%27s_theory_of_gravitation http://en.wikipedia.org/wiki/Le_Sage%27s_theory_of_gravitati...