Skip to content

Commit

Permalink
Allow rendering meshes without UV coordinate data. (#5222)
Browse files Browse the repository at this point in the history
# 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<bevy_pbr::pbr_material::StandardMaterial>"))` 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.
  • Loading branch information
komadori committed Jul 8, 2022
1 parent a7bb662 commit ddc5033
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ddc5033

Please sign in to comment.