Skip to content

Fix a few improper memory accesses in the clustered forward vertex shader #107876

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

Merged
merged 1 commit into from
Jun 24, 2025

Conversation

clayjohn
Copy link
Member

I noticed these issues while profiling the vertex shader. So far they are unreported, but they are very subtle bugs that will be extremely difficult to track down once they surface.

draw_call.instance_index should not be used directly since it doesn't take into account auto-batching. This bug will only surface when multiple meshes are batched together that have a different layers property where one should be affected by a directional light and the other shouldn't. Currently we only consider the layers property of the first mesh that is batched. With this PR, we match the behaviour of the other light types and always use the layers property that corresponds to the mesh being rendered.

scene_data_block.data should not be used directly in the vertex shader since it can change between frames and impact motion vector generation. This one is less likely to cause issues. We are only considering the

IN_SHADOW_PASS Should have been a global all along since it can only be used from inside of a function.

…ader

draw_call.instance_index should not be used directly since it doesn't take into account auto-batching

scene_data_block.data should not be used directly in the vertex shader since it can change between frames and impact motion vector generation

IN_SHADOW_PASS can only be accessed inside functions, so it needs to be a global and not a constant
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Code looks good to me.

@Repiteo Repiteo merged commit 01410f1 into godotengine:master Jun 24, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jun 24, 2025

Thanks!

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