godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.07k stars 21.18k forks source link

3D Read Screen Shaders didn't work well with SSR #90094

Open NiJingzhe opened 7 months ago

NiJingzhe commented 7 months ago

Tested versions

System information

Windows 11 - Godot v4.1.0 stable - Vulkan (Forward+) - dedicated !

Issue description

I create a Water ( a plain mesh) in my test_map.tscn, using ShaderMaterial to make refraction effect. But when I put test_map into MainWorld.tscn (With SSR open in Environment), water cannot correctly read screen texture and everything under water surface became compeletely invisible

Steps to reproduce

In MRP, you just need to switch the SSR checkbox and you can see the problem.

Minimal reproduction project (MRP)

MRP.zip

NiJingzhe commented 7 months ago

shader code is include in MRP : )

AThousandShips commented 7 months ago

You didn't wait until the MRP uploaded, please edit and try again, make sure you wait until it's been uploaded

AThousandShips commented 7 months ago

Also please try with a supported version, like 4.1.3, or 4.2.1

NiJingzhe commented 7 months ago

Got it

NiJingzhe commented 7 months ago

Also please try with a supported version, like 4.1.3, or 4.2.1

4.2.1-stable and 4.3-dev5 have been tested and both of them can reproduce this problem : )

ttencate commented 2 months ago

Screen-reading shaders go through the transparent pipeline, which is sorted after all opaque geometry has been rendered. It has to be this way, otherwise you wouldn't have a complete screen texture to read from. So essentially, a screen-reading shader is treated as a transparent material.

And currently, screen-space reflections cannot appear on transparent materials. There is an open proposal to address this: https://github.com/godotengine/godot-proposals/discussions/7274