# water reflection - non-planar problem

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

## 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 on other sites
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 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 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 Id love to hear about it.

##### 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 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 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 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 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 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 itll work when displacing the actual vertex positions though.

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 16
• 12
• 20
• 12
• 19
• ### Forum Statistics

• Total Topics
632167
• Total Posts
3004527

×