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 MTL color loading when vertices are shared across different faces #7441

Merged
merged 1 commit into from
Dec 21, 2024

Conversation

davepagurek
Copy link
Contributor

Changes:

A user on Discord discovered that their obj + mtl combo was not rendering correctly:

image

Zipped obj + mtl here

It turns out this can happen when vertices are reused between faces. Previously, when a vertex is used by a face for the first time, it adds the vertices to the p5.Geometry only if it has not been used in that color before. Then, when the face is added, it adds colors once per vertex, regardless of whether it is new or not. This means we might add a color to the color buffer a second time for a vertex that already exists in the buffer, pushing all subsequent colors out of sync.

Now, colors are added at the same time as other vertex properties. This all-or-nothing structure will hopefully help prevent some properties from going out of sync.

image

PR Checklist

@davepagurek davepagurek marked this pull request as ready for review December 21, 2024 21:14
@davepagurek davepagurek merged commit e03060a into dev-2.0 Dec 21, 2024
2 checks passed
@davepagurek davepagurek deleted the fix/mtl-color-loading branch December 21, 2024 21:18
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.

1 participant