Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The foam in the 3d water shader is shown incorrectly #18

Open
1 of 2 tasks
wojtekpil opened this issue Aug 10, 2020 · 8 comments
Open
1 of 2 tasks

The foam in the 3d water shader is shown incorrectly #18

wojtekpil opened this issue Aug 10, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@wojtekpil
Copy link

I'm submitting a...

  • Bug report.
  • Feature request.

Bug report

What is the current behavior?
Depth isn't calculated correctly for object near water. I marked the problem on the attached image:
Screenshot from 2020-08-10 22-22-11

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.

@NathanLovato NathanLovato added the bug Something isn't working label Aug 10, 2020
@Razoric480
Copy link
Contributor

Razoric480 commented Aug 17, 2020

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.

@NathanLovato
Copy link
Contributor

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.

@wojtekpil
Copy link
Author

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:
Screenshot from 2020-08-17 23-26-04
This screenshot shows that, there is still problem:
Screenshot from 2020-08-18 22-39-04
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

@Razoric480
Copy link
Contributor

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.

@Razoric480 Razoric480 reopened this Aug 18, 2020
@NathanLovato
Copy link
Contributor

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.

@wojtekpil
Copy link
Author

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.

@Razoric480
Copy link
Contributor

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.

@Razoric480
Copy link
Contributor

Razoric480 commented Aug 21, 2020

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.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants