diff --git a/crates/bevy_core_pipeline/src/core_2d/main_pass_2d_node.rs b/crates/bevy_core_pipeline/src/core_2d/main_pass_2d_node.rs index b4cea92089ed64..437e7feef4c8dc 100644 --- a/crates/bevy_core_pipeline/src/core_2d/main_pass_2d_node.rs +++ b/crates/bevy_core_pipeline/src/core_2d/main_pass_2d_node.rs @@ -80,7 +80,7 @@ impl Node for MainPass2dNode { color_attachments.push(Some(picking_textures.get_color_attachment(Operations { load: LoadOp::Clear(PickingTextures::clear_color()), store: true, - }))) + }))); } let pass_descriptor = RenderPassDescriptor { diff --git a/crates/bevy_core_pipeline/src/core_3d/main_pass_3d_node.rs b/crates/bevy_core_pipeline/src/core_3d/main_pass_3d_node.rs index d6df1e62452774..4bc7c52e1db336 100644 --- a/crates/bevy_core_pipeline/src/core_3d/main_pass_3d_node.rs +++ b/crates/bevy_core_pipeline/src/core_3d/main_pass_3d_node.rs @@ -95,7 +95,7 @@ impl Node for MainPass3dNode { color_attachments.push(Some(picking_textures.get_color_attachment(Operations { load: LoadOp::Clear(PickingTextures::clear_color()), store: true, - }))) + }))); } let pass_descriptor = RenderPassDescriptor { diff --git a/crates/bevy_pbr/src/render/mesh_types.wgsl b/crates/bevy_pbr/src/render/mesh_types.wgsl index 5a6cf288ccf8cc..dfd4e75901c658 100644 --- a/crates/bevy_pbr/src/render/mesh_types.wgsl +++ b/crates/bevy_pbr/src/render/mesh_types.wgsl @@ -3,7 +3,9 @@ struct Mesh { model: mat4x4, inverse_transpose_model: mat4x4, +#ifdef PICKING entity_index: u32, +#endif // 'flags' is a bit field indicating various options. u32 is 32 bits so we have up to 32 options. flags: u32, }; diff --git a/crates/bevy_sprite/src/mesh2d/mesh2d_types.wgsl b/crates/bevy_sprite/src/mesh2d/mesh2d_types.wgsl index 9c2c4140facbc3..dfbeee666c8dfc 100644 --- a/crates/bevy_sprite/src/mesh2d/mesh2d_types.wgsl +++ b/crates/bevy_sprite/src/mesh2d/mesh2d_types.wgsl @@ -3,7 +3,9 @@ struct Mesh2d { model: mat4x4, inverse_transpose_model: mat4x4, +#ifdef PICKING entity_index: u32, +#endif // 'flags' is a bit field indicating various options. u32 is 32 bits so we have up to 32 options. flags: u32, }; diff --git a/crates/bevy_sprite/src/render/sprite.wgsl b/crates/bevy_sprite/src/render/sprite.wgsl index 18db4d4d5cb74b..1540b563bc17be 100644 --- a/crates/bevy_sprite/src/render/sprite.wgsl +++ b/crates/bevy_sprite/src/render/sprite.wgsl @@ -18,7 +18,9 @@ var view: View; struct VertexOutput { @location(0) uv: vec2, +#ifdef PICKING @location(1) entity_index: u32, +#endif #ifdef COLORED @location(2) color: vec4, #endif @@ -29,14 +31,18 @@ struct VertexOutput { fn vertex( @location(0) vertex_position: vec3, @location(1) vertex_uv: vec2, +#ifdef PICKING @location(2) entity_index: u32, +#endif #ifdef COLORED @location(3) vertex_color: vec4, #endif ) -> VertexOutput { var out: VertexOutput; out.uv = vertex_uv; +#ifdef PICKING out.entity_index = entity_index; +#endif out.position = view.view_proj * vec4(vertex_position, 1.0); #ifdef COLORED out.color = vertex_color; diff --git a/crates/bevy_ui/src/render/ui.wgsl b/crates/bevy_ui/src/render/ui.wgsl index 523f01967876df..547f591c87f360 100644 --- a/crates/bevy_ui/src/render/ui.wgsl +++ b/crates/bevy_ui/src/render/ui.wgsl @@ -13,10 +13,12 @@ struct View { var view: View; struct VertexOutput { + @builtin(position) position: vec4, @location(0) uv: vec2, @location(1) color: vec4, +#ifdef PICKING @location(2) entity_index: u32, - @builtin(position) position: vec4, +#endif }; @vertex @@ -24,13 +26,17 @@ fn vertex( @location(0) vertex_position: vec3, @location(1) vertex_uv: vec2, @location(2) vertex_color: vec4, +#ifdef PICKING @location(3) entity_index: u32, +#endif ) -> VertexOutput { var out: VertexOutput; - out.uv = vertex_uv; out.position = view.view_proj * vec4(vertex_position, 1.0); + out.uv = vertex_uv; out.color = vertex_color; +#ifdef PICKING out.entity_index = entity_index; +#endif return out; }