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

Unexpected rendering with screen reading shader, Light2D and LightOccluder2D #47575

Open
djrain opened this issue Apr 2, 2021 · 3 comments
Open

Comments

@djrain
Copy link

djrain commented Apr 2, 2021

Godot version:
3.3 RC7

OS/device including version:
2020 Mac Mini
macOS Big Sur
GLES2 / GLES3

Issue description:
I have a 2D water shader which reads from SCREEN_TEXTURE to display whatever is behind with a refraction effect. A ColorRect and a Sprite are placed behind the water, and a Light2D affects everything. There is also a LightOccluder2D covering the sprite, set to clockwise cull mode so that the inside of the sprite remains lit.

The issue is that in the water, this results in two visible copies of the screen texture being lit, one (correctly) distorted by the shader, and the other not:

Screen Shot 2021-04-02 at 9 54 48 AM

Whereas I would hope for it to look more like this:

expected

Water shader:

shader_type canvas_item;

void fragment() {
	vec2 coord = SCREEN_UV + vec2(sin(TIME*3.0 + UV.y*10.0) * 0.02, 0.0);
	vec4 screen = textureLod(SCREEN_TEXTURE, coord, 0.0);
	COLOR = mix(vec4(0.2, 0.6, 1.0, 1.0), screen, 0.5);
	COLOR.a = 1.0;
}

The result is the same whether batching is on or off.

Steps to reproduce:
Simply run the MRP scene.

Minimal reproduction project:
ScreenTextureLightIssue.zip

@clayjohn
Copy link
Member

clayjohn commented Apr 2, 2021

Have you tried using a backbuffercopy? I wonder if the shadows are drawn after screen_texture is captured.

@djrain
Copy link
Author

djrain commented Apr 2, 2021

Have you tried using a backbuffercopy? I wonder if the shadows are drawn after screen_texture is captured.

Yeah, I tried it in various places and it didn't help.

@Calinou
Copy link
Member

Calinou commented Apr 2, 2021

Related to #44066.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants