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

nvidia rect flicker workaround (GLES3) causing shader bugs #41606

Closed
fmenozzi opened this issue Aug 29, 2020 · 13 comments
Closed

nvidia rect flicker workaround (GLES3) causing shader bugs #41606

fmenozzi opened this issue Aug 29, 2020 · 13 comments

Comments

@fmenozzi
Copy link

fmenozzi commented Aug 29, 2020

Godot version:
3.2.2.stable

OS/device including version:
OS: Ubuntu 18.04.1
Graphics card: NVidia GeForce GTX 1070/PCIe/SSE2
Backend: GLES3

Issue description:
I have a simple canvas item shader as part of an effect sequence that draws a black circle on the screen and animates the radius to expand outward, the minimum-viable version of which is reproduced below:

shader_type canvas_item;

uniform float radius_uv: hint_range(0.0, 1.0) = 0.5;

void fragment() {
    // Circle is black.
    COLOR.rgb = vec3(0.0);

    // Only show fragments within the circle.
    if (distance(UV, vec2(0.5, 0.5)) <= radius_uv) {
        COLOR.a = 1.0;
    } else {
        COLOR.a = 0.0;
    }
}

Prior to enabling the nvidia rect flicker workaround (GLES3) in the project settings, this shader behaved as expected: changing the radius_uv uniform would cause the circle to expand and contract appropriately. The shader worked both in-game and in the editor.

However, after enabling the flicker workaround and reloading the project, the shader no longer behaves correctly. Rather than animating the circle as expected, changing the radius_uv uniform now causes the screen to be blank until the uniform value exceeds 0.7, after which the entire screen turns black. The significance of 0.7 is unknown to me. This issue occurs both in-game and in the editor.

Steps to reproduce:
Load the reproduction project (which does not have the rect flicker workaround enabled) and mess around with the radius_uv uniform shader param in $World/CanvasLayer/ColorRect, observing that the black circle grows and shrinks.

Now go to project settings, enable the nvidia rect flicker workaround, reload the project, and mess around with that same uniform, observing now the issue described above.

Minimal reproduction project:
reproduce-nvidia-rect-workaround-shader-bug.zip

EDIT: I accidentally uploaded a project that enables the flicker workaround, instead of disabling it like I mentioned above. This means the shader will not work by default, rather than work by default.

@Calinou
Copy link
Member

Calinou commented Aug 29, 2020

cc @lawnjelly

@lawnjelly
Copy link
Member

I'll take a look. 👍 It's probably something like the shader isn't bound.

@fmenozzi
Copy link
Author

fmenozzi commented Aug 30, 2020

Thank you!

fmenozzi added a commit to fmenozzi/factory-escape that referenced this issue Sep 4, 2020
This reverts commit a7f67f2.

For some reason, enabling this workaround in GLES3 causes the player
death effect shader not to work anymore. In the meantime, revert the
change and wait for godotengine/godot#41606 to
provide some kind of resolution.
@fmenozzi
Copy link
Author

Any updates on this? I assume it's too late to try and get a fix in time for 3.2.3 but maybe for 3.2.4?

@lawnjelly
Copy link
Member

I did have a look and the solution wasn't as obvious as I'd hoped. It seems to be to do with the shader versioning in GLES3 causing the correct shader not to be bound if I remember right (this is done quite differently to GLES2). I need to spend some time going through it to understand the shader versioning at the same time as GLES3 batching as it may affect batching in a similar way, so it will be 3.2.4 I'm afraid.

@fmenozzi
Copy link
Author

Ok, thanks for looking!

@lawnjelly
Copy link
Member

Incidentally, anyone watching this topic should also be watching #42119, and the builds at:
https://github.com/lawnjelly/Misc/releases

The reason being, is that the batching path by default also fixes the nvidia flicker (unless you use single_rect_fallback). So if the custom shaders works ok there then this is a better solution than nvidia_workaround for the legacy path (although I will try and fix this too).

@akien-mga
Copy link
Member

Can you still reproduce the issue with 3.2.4 beta 3 or later? It should include batching for GLES3 by default. which might help here.

@fmenozzi
Copy link
Author

I'm unfortunately not at home right now and thus won't have access to my desktop (the original device for this issue) for another month or two. It also seems as though my old laptop (Lenovo T430) is no longer supported for the GLES3 backend for 3.2.4-beta4, so I can't even test on that either.

@fmenozzi
Copy link
Author

Actually, it seems as though I can switch to GLES3 from within the editor, even though the project selection dialog claims that my GPU drivers are incompatible (and thus greys out the GLES3 option entirely). I'm not sure if that is intended behavior but after switching to GLES3 from within the editor I can confirm that the the shader above works with default project settings in 3.2.4-beta4 (i.e. with batching enabled).

@Calinou
Copy link
Member

Calinou commented Dec 12, 2020

Actually, it seems as though I can switch to GLES3 from within the editor, even though the project selection dialog claims that my GPU drivers are incompatible (and thus greys out the GLES3 option entirely). I'm not sure if that is intended behavior but after switching to GLES3 from within the editor I can confirm that the the shader above works with default project settings in 3.2.4-beta4 (i.e. with batching enabled).

This is a regression in 3.2.4beta4 which will be fixed by #44302.

@Calinou
Copy link
Member

Calinou commented Oct 16, 2021

@fmenozzi Can you (or anyone else) still reproduce this bug in Godot 3.3.4 or any later release?

@fmenozzi
Copy link
Author

Seems to be working in 3.3.4 (i.e. I can't reproduce the issue; shader behaves as expected with flicker workaround both enabled and disabled).

@Calinou Calinou closed this as completed Oct 16, 2021
@Calinou Calinou added this to the 3.3 milestone Oct 16, 2021
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

4 participants