Jump to content
  • Advertisement
Sign in to follow this  
george7378

Normal mapped water is awesome

This topic is 2024 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

 

Edited by george7378

Share this post


Link to post
Share on other sites
Advertisement

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

...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 ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!