-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Screenspace quad shaders are broken #90443
Comments
That's an expected compat breakage from switching to Reverse Z for depth, see #88328 (comment). |
Interesting! I read the note for dev blog post and I'm baffled:
I'm using exactly the same code, except if clause switched to I think it's not about reverse Z for depth, it's about the quad mesh rendering behind the objects or something like that. Please try the MRP to see the issue. |
It indeed looks like a regression from the Reverse-Z PR. But I'm 99% certain the problem is the vertex shader since its clear that the mesh isn't showing up at all. edit: Yep, the problem is that the quad shader trick relies on treating the quad coordinates as clip space coordinates, so the z needs to be reversed. I.e. We will have to discuss this further with the rendering contributors. I forgot that One option is to automatically reverse the z-value for users. We could then document that POSITION is in a modified clip space where 0 is the near plane and 1 is the far plane. That would avoid compatibility breakage, but it would be pretty annoying in the long run |
Thanks, this workaround indeed works for now. ✌️ |
We discussed this at the rendering meeting tonight. Unfortunately we realized there is no good solution here. We can't simply reverse the z or the user as the user might be using proper z. For example, the following code currently works in both 4.2 and 4.3:
If we reverse the z behind the scenes, then this perfectly valid code will break instead. Accordingly, we agreed to do the following:
|
I encountered the same issue while modifying the sky shader (where The key point is, if the vertex coordinate are not using the PROJECTION_MATRIX, we (user) need to pay special attention to it. |
Exactly. The trouble is, we have no way of reliably knowing if any particular usage is correct or not. For example We discussed adding a temporary warning when using any of |
I've thought of another situation that users need to handle themselves: In Vulkan and DirectX, So we need a method in the shader to determine if the z-value of the NDC Space coordinates is in [-1,1] or [0,1], or to determine if we are currently using OpenGL or another API. For example, adding a macro definition? I'm not sure if such a macro exists now. |
We don't have such a macro. But remember, in sky shaders, users don't have access to the vertex shader or to the clip space position. Sky shaders are only fragment shaders as the vertex projection is totally handled for users. |
No,no,no, I actually refer to sky.glsl in the source code. For users, If they want to use a spatial shader to write something that is always rendered at the backmost, they will encounter the same problem. At this time they need a macro to handle both situations. |
I think I understand you now. We do have a macro to tell when the user is using the compatibility renderer, but it's not obvious. OUTPUT_IS_SRGB is true in the compatibility renderer and false otherwise. we could add a new macro CLIP_SPACE_FAR which is 0 for the Vulkan backend and -1 for OpenGL. |
Wouldn't you typically want to use |
That would certainly help in the future. The problem we are grappling with now is the number of existing shaders that are impacted. |
We have now added all the discussed changes to make this change in behaviour smoother, so I am going ahead and closing this issue. I will open a new issue to track Khasehemwy's suggestions #90443 (comment) edit: proposal here: godotengine/godot-proposals#10273 |
Tested versions
Reproducible in v4.3.dev.custom_build [a7b8602]
Not reproducible in v4.3.dev.custom_build [02488108a]
Not reproducible in v4.3.dev5
System information
Godot v4.3.dev (d0c3dfe91) - Ubuntu 20.04.6 LTS (Focal Fossa) - X11 - Vulkan (Forward+) - dedicated AMD Radeon RX 6600 (RADV NAVI23) () - AMD Ryzen 7 5800X 8-Core Processor (16 Threads)
Issue description
Working view on

02488108a
(it's my custom commit, it's somewhere after dev5). I lost the original working branch, just have the binary left 🤷Broken view on master
a7b860250
:Steps to reproduce
I uploaded a test project with a simple screenspace quad depth shader. In master it only renders on skybox, in dev5 and somewhere after it it correctly renders on top of the objects.
Minimal reproduction project (MRP)
depth-test.zip
The text was updated successfully, but these errors were encountered: