Open wojtekpil opened 4 years ago
I've issued a fix to the shader, clamping the refracted depth by the 'real' unrefracted depth. If you have anti-aliasing, there can still be a little bit of shimmering or brighter edge, but it should be minimized.
Can re-open if it's too much and explore more fixes, but it's a difficult problem to tackle.
Thanks for the fix @Razoric480.
@wojtekpil if the shader works, would you mind sharing a screenshot of your game? It's looking real cool, I'd share it on twitter. If you have a website you'd like me to share too I can post it with the screenshot.
Hi, @Razoric480, sadly it didn't fix my problem. As for my game, @NathanLovato this is only a simple test scene. Currently I moved to this new one: This screenshot shows that, there is still problem: I don't have a website but If you are interested I sometimes post my progress on yt: https://www.youtube.com/watch?v=11uUeRN_uyM
I'm not too sure how to fix it, unfortunately. If there's some aliasing issues between the depth buffer and the main view, the outline will be visible. But the foam itself should no longer be visible, or at least there shouldn't be much of it at all.
It also looks more like shadows from the trees and bushes rather than foam, but without seeing it in action or being able to play around with the camera angle it's hard to tell.
Would you have a scene to share with us? Even something simple, without sharing all your assets. That would help us fix the issue. In case you'd prefer not to publish it publicly, you can send it to me via email at nathan [at] gdquest.com and we will only use it to address the bug.
Sorry for the late reply. I was tinkering myself with some of the water settings and I think that i found the issue. Here is the simplest demo scene that i could make to reproduce it: https://drive.google.com/file/d/1OAzvjuaWjfH7WlPcnBv0XK1x4ti-FtHd/view?usp=sharing (again, I just modified original file). As you can see there is strange ghosting behind rocks, even though they're floating above water. The problems seems to be "Refraction strength" that distorts UV. If I lower the value of this parameter the problems is almost gone. So probably it's a little bit different issue now.
Okay, I see now. I've fixed the depth issue, but the UVs that sample the scene color are still distorted for the refraction. I'll see if I can fix it up.
Hrm, actually it can't really be fixed without drawing in two passes. The issue being that there's no way to get the screen texture without objects in front of the water. So the objects that are in front of the water end up in the way when it comes time to sampling the screen texture.
Reseting the UVs if the sampled depth lives above the water plane just creates unnatural refraction-less holes.
Would have to draw the scene below the water, save it as a texture somewhere, then draw the scene for the water and objects above it. But then you'd lose the effect of intersecting with the water, short of drawing objects partway submerged partially with a planar shader.
I'm submitting a...
Bug report
What is the current behavior? Depth isn't calculated correctly for object near water. I marked the problem on the attached image:
What is the expected behavior? There shouldn't be any foam around objects, that aren't in the water.
Tell us the steps to reproduce the bug, and if possible share a minimal demo of the problem.
Just add any MeshInstance to a 3d water demo scene and look at water with camera behind this node.