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

Using INV_PROJECTION_MATRIX in gdshader causes editor to 100% cpu and hang on or after compilation. #59302

Closed
danger-dan opened this issue Mar 19, 2022 · 1 comment · Fixed by #59305

Comments

@danger-dan
Copy link
Contributor

Godot version

4.0 dev 35eec4d

System information

popOS! (Ubuntu), RTX2060, Vulkan

Issue description

Editor uses 100% cpu and hangs on compilation of a shader. This happens as soon as the builtin INV_PROJECTION_MATRIX is added to the code. The only useful logs i could get which may or may not be related is:

at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:280)
ERROR: Error compiling Fragment shader, variant #7 (
#define MODE_MULTIPLE_RENDER_TARGETS
).
at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:276)
ERROR: Failed parse:
WARNING: 0:72: '' : all default precisions are highp; use precision statements to quiet warning, e.g.:
"precision mediump int; precision highp float;"
ERROR: 0:2054: 'inv_projection_matrix' : undeclared identifier
ERROR: 0:2054: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

at: _compile_variant (servers/rendering/renderer_rd/shader_rd.cpp:277)
ERROR: code:

Steps to reproduce

create new project, add new shader resource and start writing - using INV_PROJECTION_MATRIX.

tested with:

void fragment(){
float depth = texture(DEPTH_TEXTURE, SCREEN_UV).x;
vec3 ndc = vec3(SCREEN_UV * 2.0 - 1.0, depth);
vec4 view = INV_PROJECTION_MATRIX * vec4(ndc, 1.0);
}

Minimal reproduction project

No response

@clayjohn
Copy link
Member

Looks like we need to do something like this in the fragment shader

mat4 projection_matrix = scene_data.projection_matrix;
mat4 inv_projection_matrix = scene_data.inv_projection_matrix;

INV_PROJECTION_MATRIX is renamed to inv_projection_matrix by Godot's shader compiler. But the fragment shader only has access to scene_data.inv_projection_matrix so we need to define inv_projection_matrix somewhere above the user's fragment shader code.

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

Successfully merging a pull request may close this issue.

3 participants