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

Prevent changing some built-ins in spatial shaders #93269

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

Chaosus
Copy link
Member

@Chaosus Chaosus commented Jun 17, 2024

CUSTOMX are meaningless to be used as output because in shader it's defined like:
layout(location = 6) in vec4 custom0_attrib;
And canvas_item shader already has the same built-in, and it's defined as constt.

Also, BONE_WEIGHT and BONE_INDICES are affected by the same problem.

NODE_POSITION_WORLD corresponds to MODEL_MATRIX which changing is forbidden at previous lines.

CAMERA_POSITION_WORLD corresponds to INV_VIEW_MATRIX which changing is forbidden at previous lines.

CAMERA_DIRECTION_WORLD corresponds to VIEW_MATRIX which changing is forbidden at previous lines.

CAMERA_VISIBLE_LAYERS IDK about this one, but logically it should not be changed in shader.

NODE_POSITION_VIEW translated to (scene_data.view_matrix * model_matrix)[3].xyz and assigned to this one lead to shader crash.

@Chaosus Chaosus requested a review from a team as a code owner June 17, 2024 15:49
@Chaosus Chaosus added this to the 4.3 milestone Jun 17, 2024
@Chaosus Chaosus changed the title Prevent changing CUSTOM built-in in spatial shaders Prevent changing some built-ins in spatial shaders Jun 17, 2024
@Chaosus Chaosus force-pushed the shader_fix_custom branch 2 times, most recently from 44a5f5d to c6181a2 Compare June 17, 2024 16:12
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. These should be enforced as consts from the shader language side so we can provide nice errors when they are written to.

Right now users get faced with our internal shader compiler error which is not friendly and is super confusing for them

@akien-mga akien-mga merged commit 6c399a4 into godotengine:master Jun 18, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@Chaosus Chaosus deleted the shader_fix_custom branch June 18, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants