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 WebGL vertex stroke colors for retained mode + some shape modes #5928

Merged
merged 2 commits into from
Jan 6, 2023

Conversation

davepagurek
Copy link
Contributor

Resolves #5926

Changes:

  • Makes sure vertex stroke colors are duplicated along with fill colors when using QUADS, QUAD_STRIP, etc
  • Uses separate buffers arrays representing the data sent to the line shader (lineVertexColors) from the per-vertex color info (now called vertexStrokeColors)
    • This is because we must ALWAYS supply vertex color attribute data to the line shader, otherwise the buffer's stride+offset will be wrong
    • We now determine whether to use per-vertex stroke colors by checking if the user-supplied per vertex colors (vertexStrokeColors) is empty, now that the one used for rendering will always be filled
  • Updated the TESS mode per-vertex interpolation code to use less hardcoded lengths. We don't actually need to change the length here since TESS only applies to fills, not strokes, but I've kept this minor refactor in anyway to make the code more maintainable for if we need to add more in the future, as I initially thought we would here

Screenshots of the change:

BeforeAfter

image

image

Live: https://editor.p5js.org/davepagurek/sketches/DIb8nX4-C

PR Checklist

  • npm run lint passes
  • [Inline documentation] is included / updated
  • [Unit tests] are included / updated

@inaridarkfox4231
Copy link
Contributor

I see, it was better to separate the array used to configure the vertex colors and the array sent to the shader... Thanks for the fix!

@inaridarkfox4231
Copy link
Contributor

I'm sorry, I'm using "lineVertexColors" to get the vertex colors of the lines in bezierVertex() and quadraticVertex() which was recently merged, so I feel like I have to change that to "vertexStrokeColors" as well.

@davepagurek
Copy link
Contributor Author

ooh good catch, I'll change it there too!

@inaridarkfox4231
Copy link
Contributor

And...for bezierVertex() and quadraticVertex(), I didn't add a unit test for line vertex color interpolation, but that might have prevented it...wouldn't it be nice to add that as well?

@davepagurek
Copy link
Contributor Author

agreed, I'll add some new tests when I make those changes.

@inaridarkfox4231
Copy link
Contributor

Thank you for even preparing a test for _useLineColor! It's certainly safer...

@davepagurek davepagurek merged commit b7c1070 into processing:main Jan 6, 2023
@davepagurek davepagurek deleted the fix/vertex-stroke-colors branch January 6, 2023 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebGL stroke color interpolation breaks strokes when using QUADS or retained geometry
2 participants