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

Allow for usage of GLTF primitives that have no texcoords #1010

Conversation

4-rodrigo-salazar
Copy link
Contributor

@4-rodrigo-salazar 4-rodrigo-salazar commented Dec 6, 2020

I purchased a model from cgtrader.com where the gltf file describes the model using just base colors (no textures and no texcoords on primitives, which is valid gltf), and it panics when bevy tries to load the gltf and compile the pipeline.

Bevy GLTF loader creates the mesh with no UV attributes, as expected. When it attempts to compile the pipeline we get an error saying that it expected a Vertex_Uv attribute but it's not supplied by the mesh.

thread 'Compute Task Pool (5)' panicked at 'Attribute Vertex_Uv is required by shader, but not supplied by mesh. Either remove the attribute from the shader or supply the attribute (Vertex_Uv) to the mesh. ', crates\bevy_render\src\pipeline\pipeline_compiler.rs:223:17

This changes makes it so that the forward shader uv attributes get enabled with STANDARDMATERIAL_ALBEDO_TEXTURE since the gltf loader uses PbrBundle/StandardMaterial. The uv attribute today is only used when STANDARDMATERIAL_ALBEDO_TEXTURE is enabled in the fragment shader.

Tested FlightHelmet and my gltf which has no texcoords, both work now.

@Moxinilian Moxinilian added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen labels Dec 6, 2020
@4-rodrigo-salazar 4-rodrigo-salazar changed the title Allow for usage of GLTF primitives that don't use textures Allow for usage of GLTF primitives that have materials without textures Dec 6, 2020
@4-rodrigo-salazar 4-rodrigo-salazar changed the title Allow for usage of GLTF primitives that have materials without textures Allow for usage of GLTF primitives that have no texcoords Dec 6, 2020
@cart
Copy link
Member

cart commented Dec 9, 2020

Hmm I think the problem shouldn't be resolved in shaders. That puts to much burden on the shader author to support every potential input mesh.

Instead I think this should either be fixed by:

  1. inserting empty uvs into the mesh asset before rendering (a manual user action)
  2. automatically inserting zero-ed out buffers for meshes with missing vertex attributes. Mesh overhaul with custom vertex attributes #592 #599 used to do this, but it was removed and tabled for a later date. This feels like the most user-friendly approach, but it will take some finesse to get the UX and performance right.

Post processing your mesh with (1) in app code should be a decent workaround. (2) is the solution I want to shoot for.

@4-rodrigo-salazar
Copy link
Contributor Author

Cool, i'll try to take a look at implementing what you described as 2.

Thanks for thinking about this!

Base automatically changed from master to main February 19, 2021 20:44
@cart
Copy link
Member

cart commented Mar 6, 2021

Closing this as it will require a different implementation (as discussed above)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants