Jump to content
  • Advertisement
jonwil

DX11 Ideas for adding water to our engine?

Recommended Posts

I am the lead developer on a D3D11 game (using pixel and vertex shaders) that has water done as a flat mesh with textures on it (we use something similar to bump mapping to produce the water effect as well as scrolling the texture) but we want something better. Are there any tutorials on how to get cool looking water in a game? Particularly I am interested in refraction (whatever it is that lets you see what's under the water but the water obscures/distorts it a bit) and that kind of thing rather than reflection or wave motion.

 

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)

You can copy the final image to a buffer. Render the water plane converting the 4 coordinates to screenspace so that the water plane matches the final texture exactly. Then run a distortion image to distort the  underlying objects. This can be as simple as a black and white texture that is a noise texture and you can offset the current pixel by the noise texture amount. As long as you keep depth testing on etc, it will only distort pixels where water renders.  Honestly, it depends on what technique you want to mimic. I would look at some games or youtube water rendering demos and see which one is easiest that you like.

Edited by dpadam450

Share this post


Link to post
Share on other sites

It's Java and OpenGL but the concepts are the same regardless of API, should be very simple to transfer over to D3D11.  It's an 8 part series:
 

 

Share this post


Link to post
Share on other sites

This all depends on what kind of effect are you going to achieve.

 

There is vast difference between dynamic water (flooding, etc.) and static water (ponds, lakes, ocean, rivers, puddles, etc.). I assume you want the latter - focusing on rivers, ocean, etc. You will find out that (if possible) you will need a separate solution for each case (at least in my engine it has been separated), each using a bit different shaders and maps - ends up in acceptable result. There is no solution that would 'rule them all'.

 

Generally each water surface will have refrection & reflection. For larger water surfaces you will need to calculate also color (greenish/blueish effect that depends on depth of water), some will require large waves (ocean - I believe tessellated FFT based ocean is still state of the art), smaller just bump maps. Rivers will also require flow maps and particles. Fluid dynamics can make this more alive.

For reflection you want to use cubemaps (puddles, rivers) and plannar reflections (ponds, lakes, ocean) ... or raytraced/voxel based if you can afford those (cheap screen space ray tracing works too).

For refraction - just render your scene without all water, that should be enough for refraction - use camera matrix to project this to water surfaces when rendering those, and with help of normal/dudv/flow maps - do a distortion.

Mixing between refraction and reflection should be based on fresnel.

 

If you have any particular question - feel free to ask specifically (i.e.'How to do reflection' or 'How to animate rivers'). I'll try to answer in detail.

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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!