From e52853b0874f77089dd8c6e4e4b250532d940a15 Mon Sep 17 00:00:00 2001 From: idoba Date: Tue, 3 Oct 2023 21:24:43 +0300 Subject: [PATCH 1/2] Fixed: Use VertexOuput instead of FragmentInput in prepass.wgsl - solves inconsistency between vertex and fragment shader (#9402) --- crates/bevy_pbr/src/prepass/prepass.wgsl | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/crates/bevy_pbr/src/prepass/prepass.wgsl b/crates/bevy_pbr/src/prepass/prepass.wgsl index 396935ff411e7..defcf836482c2 100644 --- a/crates/bevy_pbr/src/prepass/prepass.wgsl +++ b/crates/bevy_pbr/src/prepass/prepass.wgsl @@ -142,24 +142,6 @@ fn vertex(vertex_no_morph: Vertex) -> VertexOutput { } #ifdef PREPASS_FRAGMENT -struct FragmentInput { -#ifdef VERTEX_UVS - @location(0) uv: vec2, -#endif // VERTEX_UVS - -#ifdef NORMAL_PREPASS - @location(1) world_normal: vec3, -#endif // NORMAL_PREPASS - -#ifdef MOTION_VECTOR_PREPASS - @location(3) world_position: vec4, - @location(4) previous_world_position: vec4, -#endif // MOTION_VECTOR_PREPASS - -#ifdef DEPTH_CLAMP_ORTHO - @location(5) clip_position_unclamped: vec4, -#endif // DEPTH_CLAMP_ORTHO -} struct FragmentOutput { #ifdef NORMAL_PREPASS @@ -176,7 +158,7 @@ struct FragmentOutput { } @fragment -fn fragment(in: FragmentInput) -> FragmentOutput { +fn fragment(in: VertexOutput) -> FragmentOutput { var out: FragmentOutput; #ifdef NORMAL_PREPASS From f7ed973cbfadca36deaf0a6ea6a02363c38f47c4 Mon Sep 17 00:00:00 2001 From: idoba Date: Wed, 4 Oct 2023 09:07:38 +0300 Subject: [PATCH 2/2] CR - rename clip_position to position and VertexOutput to PrepassMeshVertexOutput --- crates/bevy_pbr/src/prepass/prepass.wgsl | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/bevy_pbr/src/prepass/prepass.wgsl b/crates/bevy_pbr/src/prepass/prepass.wgsl index defcf836482c2..e3dc9050664fd 100644 --- a/crates/bevy_pbr/src/prepass/prepass.wgsl +++ b/crates/bevy_pbr/src/prepass/prepass.wgsl @@ -32,8 +32,8 @@ struct Vertex { #endif // MORPH_TARGETS } -struct VertexOutput { - @builtin(position) clip_position: vec4, +struct PrepassMeshVertexOutput { + @builtin(position) position: vec4, #ifdef VERTEX_UVS @location(0) uv: vec2, @@ -78,8 +78,8 @@ fn morph_vertex(vertex_in: Vertex) -> Vertex { #endif @vertex -fn vertex(vertex_no_morph: Vertex) -> VertexOutput { - var out: VertexOutput; +fn vertex(vertex_no_morph: Vertex) -> PrepassMeshVertexOutput { + var out: PrepassMeshVertexOutput; #ifdef MORPH_TARGETS var vertex = morph_vertex(vertex_no_morph); @@ -95,10 +95,10 @@ fn vertex(vertex_no_morph: Vertex) -> VertexOutput { var model = bevy_pbr::mesh_functions::get_model_matrix(vertex_no_morph.instance_index); #endif // SKINNED - out.clip_position = bevy_pbr::mesh_functions::mesh_position_local_to_clip(model, vec4(vertex.position, 1.0)); + out.position = bevy_pbr::mesh_functions::mesh_position_local_to_clip(model, vec4(vertex.position, 1.0)); #ifdef DEPTH_CLAMP_ORTHO - out.clip_position_unclamped = out.clip_position; - out.clip_position.z = min(out.clip_position.z, 1.0); + out.clip_position_unclamped = out.position; + out.position.z = min(out.position.z, 1.0); #endif // DEPTH_CLAMP_ORTHO #ifdef VERTEX_UVS @@ -142,7 +142,6 @@ fn vertex(vertex_no_morph: Vertex) -> VertexOutput { } #ifdef PREPASS_FRAGMENT - struct FragmentOutput { #ifdef NORMAL_PREPASS @location(0) normal: vec4, @@ -158,7 +157,7 @@ struct FragmentOutput { } @fragment -fn fragment(in: VertexOutput) -> FragmentOutput { +fn fragment(in: PrepassMeshVertexOutput) -> FragmentOutput { var out: FragmentOutput; #ifdef NORMAL_PREPASS