From 3537c6ae2d0d9af35bf7aa4cb31c4378ecf49c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Wed, 30 Mar 2022 19:56:16 +0000 Subject: [PATCH] Fix animation: shadow and wireframe support (#4367) # Objective Animation with shadows crashes with: ``` thread 'main' panicked at 'wgpu error: Validation Error Caused by: In Device::create_render_pipeline note: label = `shadow_pipeline` error matching VERTEX shader requirements against the pipeline shader global ResourceBinding { group: 1, binding: 1 } is not available in the layout pipeline layout visibility flags don't include the shader stage ``` Animation with wireframe crashes with: ``` thread 'main' panicked at 'wgpu error: Validation Error Caused by: In Device::create_render_pipeline note: label = `opaque_mesh_pipeline` error matching VERTEX shader requirements against the pipeline shader global ResourceBinding { group: 2, binding: 0 } is not available in the layout pipeline layout binding is missing from the pipeline layout ``` ## Solution - Fix the bindings --- crates/bevy_pbr/src/render/light.rs | 4 +++- crates/bevy_pbr/src/render/wireframe.wgsl | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 002d5d6afa..fbffe9cd02 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -261,7 +261,7 @@ impl SpecializedMeshPipeline for ShadowPipeline { ) -> Result { let mut vertex_attributes = vec![Mesh::ATTRIBUTE_POSITION.at_shader_location(0)]; - let mut bind_group_layout = vec![self.view_layout.clone(), self.mesh_layout.clone()]; + let mut bind_group_layout = vec![self.view_layout.clone()]; let mut shader_defs = Vec::new(); if layout.contains(Mesh::ATTRIBUTE_JOINT_INDEX) @@ -271,6 +271,8 @@ impl SpecializedMeshPipeline for ShadowPipeline { vertex_attributes.push(Mesh::ATTRIBUTE_JOINT_INDEX.at_shader_location(4)); vertex_attributes.push(Mesh::ATTRIBUTE_JOINT_WEIGHT.at_shader_location(5)); bind_group_layout.push(self.skinned_mesh_layout.clone()); + } else { + bind_group_layout.push(self.mesh_layout.clone()); } let vertex_buffer_layout = layout.get_layout(&vertex_attributes)?; diff --git a/crates/bevy_pbr/src/render/wireframe.wgsl b/crates/bevy_pbr/src/render/wireframe.wgsl index 66d91653f7..39c5f44385 100644 --- a/crates/bevy_pbr/src/render/wireframe.wgsl +++ b/crates/bevy_pbr/src/render/wireframe.wgsl @@ -17,7 +17,7 @@ struct VertexOutput { }; #ifdef SKINNED -[[group(2), binding(0)]] +[[group(1), binding(1)]] var joint_matrices: SkinnedMesh; #import bevy_pbr::skinning #endif