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

Vulkan: Sky not blurred by textureLod shader #61969

Open
bramreth opened this issue Jun 12, 2022 · 5 comments · May be fixed by #84684
Open

Vulkan: Sky not blurred by textureLod shader #61969

bramreth opened this issue Jun 12, 2022 · 5 comments · May be fixed by #84684

Comments

@bramreth
Copy link

Godot version

4.0.a9

System information

Windows 10, NVidia 2070 Super, Vulkan

Issue description

When blurring the screen with a textureLod shader I noticed the sky wasn't blurring with the rest of the meshes in my scene as of alpha 9.

image

The attached projects works as expected in alpha 8, but not in alpha 9.

blur

Steps to reproduce

Add a world environment and camera to a scene, point the camera at a mesh so the background environment is visible.

Add a TextureRect that covers the screen and add a shader that uses the textureLod function to blur the screen.

shader_type canvas_item;

void fragment() {
	vec4 t = textureLod(SCREEN_TEXTURE, SCREEN_UV, 4.0);
	// I also darken it to make the changes more visible
	t.rgb *= 0.5;
	COLOR = t;
}

Minimal reproduction project

BrokenBlur.zip

@Calinou
Copy link
Member

Calinou commented Jun 12, 2022

cc @clayjohn

@Calinou Calinou changed the title sky not blurred by textureLod shader Vulkan: Sky not blurred by textureLod shader Jun 12, 2022
@clayjohn
Copy link
Member

Looks like it is caused by #61109

CC @Chaosus and @BastiaanOlij

The BackBuffer somehow ends up with an alpha of 0 so when applied over the original scene it adds nothing.

A temporary workaround until this bug is fixed is to ignore the alpha channel in your shader. i.e. add COLOR.a = 1.0 at the end.

@Chaosus
Copy link
Member

Chaosus commented Jun 24, 2022

I don't know yet how to fix this bug but my intuition say me that #61109 is correct and the problem is somewhere else (it only make it visible).

@clayjohn
Copy link
Member

I don't know yet how to fix this bug but my intuition say me that #61109 is correct and the problem is somewhere else (it only make it visible).

The trouble is that during the main rendering pass, we allow writing to the alpha channel of the backbuffer texture It is just ignored later on if transparent background is disabled. We had the same issue in the 3.x branch and I ended up fixing by adding an IGNORE_ALPHA shader version that would be used when transparent background is disabled.

The other solution is to do a comprehensive audit of our alpha rendering pass and ensure that alpha is not written to when transparent background is disabled

@clayjohn
Copy link
Member

This is still a problem in RC3. We need to disable copying the alpha channel of the 3D buffer to the 2D buffer when the viewport is not transparent

@clayjohn clayjohn modified the milestones: 4.0, 4.x Feb 23, 2023
@akien-mga akien-mga modified the milestones: 4.x, 4.3 Nov 14, 2023
@github-project-automation github-project-automation bot moved this to For team assessment in Rendering Issue Triage May 16, 2024
@clayjohn clayjohn moved this from For team assessment to In progress / Assigned in Rendering Issue Triage May 16, 2024
@clayjohn clayjohn moved this to In progress / Assigned in Rendering Issue Triage May 16, 2024
@clayjohn clayjohn modified the milestones: 4.3, 4.x Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In progress / Assigned
Development

Successfully merging a pull request may close this issue.

5 participants