Normal mapped water is awesome

Started by
3 comments, last by george7378 10 years, 10 months ago

Well, I've been practicing a lot with HLSL lately, and I've always wanted to make some decent water. I tried the usual technique of animated normal maps, and it's awesome! I'm using the same normal map tiled twice, with different texture coordinates each time, which removes the need for two different normal maps.

[attachment=15885:WaterNMap2.jpg]

[attachment=15886:WaterNMap1.jpg]

Anyway, just thought I'd make this post because I'm pretty pleased with the results.

Also, here's a video (probably more useful!):

Advertisement

Might aswell add this in here too - the same program but with refraction modelled too:

Can you describe in more detail the refraction part of the technique?

Sure, the process is:

1. Render the container (and anything else that is fully or partially immersed in the water) to an offscreen texture (same size/format as the back buffer - basically a copy of what you see on the screen). This is the refraction map, which you later apply to the plane of the water.

2. Render the plane using normal mapping, and apply the texture you previously stored to it. The refraction is simply determined by how you sample the texture - to create the effect I add on the xz components of the normal vector to the texture coordinates. This way, you sample from the texture based on the curvature of the water at that point in the pixel shader.

It's not 'true' refraction (it doesn't use raytracing) but it creates exactly the same effect as you'd see, with small differences.

Here's a proper tutorial: http://www.rastertek.com/dx10tut29.html

...and I might aswell share the 'final' version - now with reflections and the Fresnel term for lerping between reflection and refraction:

This is the last one, I promise ;)

This topic is closed to new replies.

Advertisement