Jump to content
  • Advertisement
Sign in to follow this  
Hiyar

Basic Water Rendering Question

This topic is 2834 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

Hi,
I am rendering water using refraction, reflection, fog and a single water plane that is the size of the terrain.
But I want the water surface to be "infinite" and move with the camera position. Does this make sense?
and how can I generate the water geometry in this case.

Also I would like to know how to cull water if it is under the terrain and not visible. Basically I want to know what kind of geometry should I use for water rendering. It is of couse just a plane because I am using clipping plane reflection texture etc.
Thanks in advance

[Edited by - Hiyar on December 14, 2010 9:56:20 AM]

Share this post


Link to post
Share on other sites
Advertisement
I have an idea for rendering your water - don't know how feasible it is though. If you truly want it infinite then you could render a full screen quad and use a screenspace technique. In your pixel shader implement the plane equation to calculate if it's on the water plane and if it is then how far away it is and render it with that data.

Alternatively just have a really big mesh that you always render centered around the camera (like you would a skydome). Use fogging to fade out as it approaches the far plane or some appropriate distance.

I wouldn't bother culling water at the triangle level. If your shader is expensive then render the terrain and set the stencil mask. Then render the water with stencil test enabled.

Share this post


Link to post
Share on other sites
Ok thanks, I want to do it like rendering a skydome always centered around the camera.

Another issue is rendering underwater. Currently I am just changing backface culling but I think this is not the proper way of doing it, is it?
And there are also some artifacts on the areas where water meets the terrain surface when cam is far away it looks ugly, how can I solve this problem.

Thanks

Share this post


Link to post
Share on other sites
You're getting z-fighting where they are close to each other due to lack of precision it seems to the GPU that they have the same depth. The easiest fix would be to move the near plane further out until the problem goes away.

Alternatively you could use the stencil approach I mentioned in the previous post. This would mean the water and the terrain do not blend which will be an issue if your water is transparent.

Share this post


Link to post
Share on other sites
But I am getting the artifacts on the water surface aswell, reflection and refraction textures are not correctly applied on the water surface when camera is far away, probably this is due lack of precision.

And what about underwater rendering? should I render water two sided? Disable backface culling?

Share this post


Link to post
Share on other sites
here is a little screenshot Click

you can see the artifacts, when it is faraway, rendertarget textures are not correct.
How do I fix this properly.

Share this post


Link to post
Share on other sites
I think the problem is related to reflections/refractions sampling from texels which are clipped - that is why they are (cornflower?) blue ...

I solve this in my water by transform the world up vector via view space into texture space and sliding the texture coordinates to close the gap

I experiment with an offset float until it looks ok

I tried other approaches but this works best

Curious how others solve it ...

(edit) there is a bunch of Shark videos here that show it

http://www.youtube.com/FloodleObb

[Edited by - skytiger on December 18, 2010 3:26:32 AM]

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.

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!