Basic Water Rendering Question

Started by
6 comments, last by skytiger 13 years, 4 months ago
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]
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.
Make the Water independent of the World Matrix and the View Matrix's x and z offsets...
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
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.
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?
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.
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]

This topic is closed to new replies.

Advertisement