Jump to content
  • Advertisement
Sign in to follow this  
gamelife

water reflection - non-planar problem

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

So I've just implemented water reflection using the common two-pass method (render reflected geometry to texture + projective texturing). It works when the water surface is fully planar. However, when the surface is animated, artifacts appear at regions that are risen above the original plane used for reflection rendering. Here is a screenshot showing the issue. Any suggestions? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
I think this has been discussed a few different times in the past couple of months. I will look for one of the threads...

Could you try to only animate the normals instead of animating the vertex position? I haven't tried this particular method, but maybe it would help.

Good Luck!

By the way, where did you get the land texture? Just curious.

Share this post


Link to post
Share on other sites
Hmm, only animating the normals could eliminate the artifacts, but the water would lose realism when you come close to it (I guess, I haven't tried yet). Btw, seems there is no other choice...

Quote:
By the way, where did you get the land texture? Just curious.


The terrain is textured using one detail map + one coarse map - downloaded from lemog.club.fr/index.html.

Share this post


Link to post
Share on other sites
I had the exact same problem too when doing my water, in the end had to resort to just using an animated bump map. Even when using this I still get a bit of a gap in the reflection at the edges of the water (screenshot)
The problem is caused when you distort the texture coordinates using the reflection vector and you get coordinates that are out of the range of the reflection in the projected texture. If you find a good solution to the problem I`d love to hear about it.

Share this post


Link to post
Share on other sites
i think some vendors such as ATI support mirror_once. i know this is an extension in opengl, not sure how to set it up in directx. tbh i don't exactly remember how to set it up. just an idea.

Share this post


Link to post
Share on other sites
nvm, this is not what i was thinking. you could still use it, but you would have to scale your UV coordinates it would just be weird.

Share this post


Link to post
Share on other sites
If you want to get rid of the displacements artifacts around object edges, your best bet would be to scale down the amount of reflection/refraction diplacement as the pixels approach the edges of your terrain. For example, you could generate an alpha map based on water depth so that the color is 0 at sea level and 1 at some arbitrary depth. Then you compute the xy-displacements in screenspace (in a rendertarget) and scale that by your alpha map. What will happen is waves will get smaller as you get closer to land and bigger toward deep water.

Share this post


Link to post
Share on other sites
That sounds like a good method blue_knight, someones suggested it to me before also, but how do you calculate the depth of the water efficiently?

Share this post


Link to post
Share on other sites
I thought about this in past days and arrive at the same solution as blue_knight's :) I tried to implement it and post a new screenshot, but I'm still stuck with some shader bugs. Anyway, I think the idea should work.

Basically, when rendering the land in normal view (i.e. not for reflection), store each pixel's world-space height somewhere (e.g. alpha channel, if available). Make this available as texture for water rendering. Water depth is calculated from water height - land height. Note that this sampling step is anyway required for local refraction, so no much extra cost is incurred.

Share this post


Link to post
Share on other sites
Just got the depth testing method working and it works great, Have eventually fixed this prob that have had for ages! Not 2 sure how well it`ll work when displacing the actual vertex positions though.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!