-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add support for custom glTF vertex attributes. #5370
Add support for custom glTF vertex attributes. #5370
Conversation
07a0fbc
to
fde3461
Compare
codes looks good in the loader, but the example could do with a lot more explanation of what's going on, why there is a custom attribute, how it's used, ... |
Thanks @mockersf for reviewing this. I've added some explanatory comments to the example. The choice of use-case for a custom attribute in the example is arbitrary, but I thought this was quite visually fun without being too complicated. |
f4ea337
to
def0fa0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just need to source the barycentric.glb
file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bevy policy is to have gltf
(plain text version) formats if possible. I think this one should be added as a gltf
, especially given it won't be large.
Also: where does the file come from? Did you make it yourself? Regardless, you should add a line to the CREDITS.md
stating the source and license. If you made it yourself, in this particular case, I'd recommend CC0 (public domain)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was generated by this scratch program: https://github.com/komadori/mk_bary_gltf
The program and by extension its output are dual licensed under the MIT and Apache 2.0 licenses.
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
Also, could you add the following to your PR description:
|
You added a new example but didn't update the readme. Please run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM: Let's Get This Merged.
The API is justified by the fact you need a bridge between the glTF attribute and the wgsl-accessible vertices. Otherwise, it wouldn't be possible to specify a location(X)
in shader.
Thanks @nicopap for the review. Now this PR has two approvals, should the S-Ready-For-Final-Review label be added? |
I actually do not exactly understand the rules behind "Read for final review" but it looks like it is as you describe: Point 2 of the "Maintainers" section https://github.com/bevyengine/bevy/blob/main/docs/the_bevy_organization.md#maintainer |
This was in fact ready-for-final-review: thanks for adding the label! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good migration guide, solid review process, no merge conflicts. I still hate the 2D vs 3D example division, but that's not a fight for this PR. gh pr checkout 5370: let's try out the new example. Works great, clear docs.
Code itself looks solid: great error handling! Let's merge!
Objective
The objective is to be able to load data from "application-specific" (see glTF spec 3.7.2.1.) vertex attribute semantics from glTF files into Bevy meshes.
Solution
Rather than probe the glTF for the specific attributes supported by Bevy, this PR changes the loader to iterate through all the attributes and map them onto
MeshVertexAttribute
s. This mapping includes all the previously supported attributes, plus it is now possible to add mappings using theadd_custom_vertex_attribute()
method onGltfPlugin
.Changelog
custom_gltf_vertex_attribute.rs
example to illustrate loading custom vertex attributes.Migration Guide
GltfPlugin
using the unit-like struct syntax, you must instead useGltfPlugin::default()
as the type is no longer unit-like.