From ddc50335143e741aa91ba09b38c6e5e8570b4408 Mon Sep 17 00:00:00 2001 From: Robin KAY Date: Fri, 8 Jul 2022 20:55:08 +0000 Subject: [PATCH] Allow rendering meshes without UV coordinate data. (#5222) # Objective Bevy requires meshes to include UV coordinates, even if the material does not use any textures, and will fail with an error `ERROR bevy_pbr::material: Mesh is missing requested attribute: Vertex_Uv (MeshVertexAttributeId(2), pipeline type: Some("bevy_pbr::material::MaterialPipeline"))` otherwise. The objective of this PR is to permit this. ## Solution This PR follows the design of #4528, which added support for per-vertex colours. It adds a shader define called VERTEX_UVS which indicates the presence of UV coordinates to the shader. --- src/loader.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/loader.rs b/src/loader.rs index f110782..b40b6e9 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -260,11 +260,6 @@ async fn load_gltf<'a, 'b>( .map(|v| VertexAttributeValues::Float32x2(v.into_f32().collect())) { mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, vertex_attribute); - } else { - let len = mesh.count_vertices(); - let uvs = vec![[0.0, 0.0]; len]; - bevy_log::debug!("missing `TEXCOORD_0` vertex attribute, loading zeroed out UVs"); - mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, uvs); } if let Some(vertex_attribute) = reader