-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Allowing glTFs to be loaded that don't have uvs and normals #406
Conversation
…ng missing attributes them with zeros
This is a nice temporary fix, but I think I would actually prefer it if loaded GLTFs only contained the attributes that have been specified. The I think we should extend Mesh to (optionally) fill in missing attributes with zeros. |
|
…by filling missing attributes them with zeros" This reverts commit e16ddb3.
Okay, so something like this: pub enum MissingVertexAttributeBehaviour{
/// Attribute doesn't need to contain meaningfull data. Example: VertexColor
DefaultValue(VertexAttributeValues //TODO),
/// Attribute is optional, but must contain meaningfull data.
/// Example: eg. SecondaryUV for lightmaps which can also be the PrimaryUV
/// Cool Trick?: instead of cloning the fallback buffer, bind it to the same slot as the missing one
FallbackAttribute(Cow<'static, str>),
/// attribute is required. Example: VertexPosition
Panic,
} Or do you think thats too verbose? |
Hmm I think short term I'd prefer something simpler like this. fn get_vertex_buffer_bytes(&self, vertex_buffer_descriptor: &VertexBufferDescriptor, fill_in_missing_attributes: bool) -> Result<Vec<u8>, MeshToVertexBufferError> {
/* existing logic here, but fill in missing attributes with zeros */
} If later consumers decide that its overly limiting, we can revisit it. But I'm guessing this will be "good enough". |
okay, new commit online 🙂 |
haha i totally forgot we were already generating arrays filled with zeros 😄 |
…ne#406) allowing gltfs to be loaded that don't have uvs and normals, by filling missing attributes them with zeros
Issue
Bevy will panic when rendering a glTF mesh that doesn't have UVs and normals
Fix
UVs and normal attributes will now be filled up with zeros.
Generally I think it is a better approach to fill up missing attributes with zeros. That will make it easier to deal with different meshs from render side.
Risks
It is now mandatory for the mesh to contain a position attribute. I really can't think of a case were a mesh wouldn't contain that, but may someone else has. 🤔