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

Fix shader crash on zero vector and negative x vector in particles processing #90810

Conversation

Arnklit
Copy link
Contributor

@Arnklit Arnklit commented Apr 17, 2024

This fixes issues where the GPU particles would crash if the axis vector was set to Vector3(0.0, 0.0, 0.0) or Vector3(-1.0, 0.0, 0.0). I fixed it by defaulting to the z axis if a zero axis is entered, as that is the default in the inspector and by absoluting the axis before calculating the matrix for particle spawning.

On the CPU particles side. a zero vector would cause "The axis Vector3 must be normalized." error. So I applied the same fixes on the CPU side.

Note the -x vector issue doesn't always occur, but it crashed the particle shader on my AMD GPU. But it makes sense to avoid it as you wouldn't be able to do the cross product of Vector(1.0, 0.0, 0.0) and Vector(-1.0, 0.0, 0.0).

@Arnklit Arnklit requested a review from a team as a code owner April 17, 2024 16:46
@Arnklit Arnklit changed the title Fix shader crash on zero vector and negative x vector Fix shader crash on zero vector and negative x vector in particles processing Apr 17, 2024
@AThousandShips AThousandShips added this to the 4.3 milestone Apr 17, 2024
@AThousandShips AThousandShips requested a review from a team April 17, 2024 16:47
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.

Makes sense!

@clayjohn clayjohn added the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Apr 17, 2024
@akien-mga akien-mga merged commit 54ba8d6 into godotengine:master Apr 17, 2024
16 checks passed
@akien-mga
Copy link
Member

akien-mga commented Apr 17, 2024

Thanks! And congrats for your first merged core engine contribution 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release crash topic:shaders topic:3d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants