Sign in to follow this  
george7378

Normal mapped water is awesome

Recommended Posts

george7378    1441

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!):

 

http://www.youtube.com/watch?v=JlqWZ2BKMxM

Edited by george7378

Share this post


Link to post
Share on other sites
george7378    1441

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

Share this post


Link to post
Share on other sites
george7378    1441

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

 

http://www.youtube.com/watch?v=kazuZtlQ0-A

 

This is the last one, I promise ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this