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 USERDATA built-ins for GLES3 particle shaders #89094

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

permelin
Copy link
Contributor

@permelin permelin commented Mar 2, 2024

When using any of USERDATA1-6 in a particle shader with the compatibility renderer, every particle except the first one would glitch out due to a buffer stride mismatch.

This PR addresses that and some related issues:

  1. When setting flags in specialization for active userdatas, the wrong bit offset was used.
  2. Userdata values were not carried over between frames.
  3. Enabling individual userdatas was done only based on the count of userdatas in the particle shader. So if the shader only used for example USERDATA6 that would give a count of one and hence USERDATA1 was enabled instead, causing the shader to fail to compile.

NOTE: To make it possible to use any of the six userdatas without requiring that 1 is used before 2 and so on, I had to remove the layout locations on the inputs. I don't have nearly enough knowledge to understand if that is safe or if there is a better way. I need a maintainer to give feedback on this.

@permelin permelin requested a review from a team as a code owner March 2, 2024 18:25
@AThousandShips AThousandShips added this to the 4.3 milestone Mar 2, 2024
@clayjohn
Copy link
Member

clayjohn commented Mar 7, 2024

NOTE: To make it possible to use any of the six userdatas without requiring that 1 is used before 2 and so on, I had to remove the layout locations on the inputs. I don't have nearly enough knowledge to understand if that is safe or if there is a better way. I need a maintainer to give feedback on this.

I think this will be fine. The GL spec allows you to specify binding points in the shader, using glVertexAttrib, or by allowing the driver to figure it out. In this case, you are allowing the driver to figure it out. For a simple shader like this, I think that is a totally fine choice.

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.

Looks great! Tested locally and it works.

@akien-mga akien-mga changed the title Fix USERDATA built-ins for GLES3 particle shaders Fix USERDATA built-ins for GLES3 particle shaders Mar 8, 2024
@akien-mga akien-mga merged commit 1186d4a into godotengine:master Mar 8, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@mikejohnstn
Copy link

Thanks for finding this. Even trying to set USERDATA1 (not even read it) was causing all particles after the first to glitch for me in compatibility. This fixed it.

@permelin permelin deleted the fix-particle-userdata-gles3 branch March 19, 2024 18:27
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.

5 participants