Skip to content

Commit

Permalink
Make the prepass shader compile when lightmaps are present. (#13402)
Browse files Browse the repository at this point in the history
Commit 3f5a090 added a reference to
`STANDARD_MATERIAL_FLAGS_BASE_COLOR_UV_BIT`, a nonexistent identifier,
in the alpha discard portion of the prepass shader. Moreover, the logic
didn't make sense to me. I think the code was trying to choose between
the two UV sets depending on which is present, so I made it do that.

I noticed this when trying Bistro with #13277. I'm not sure why this
issue didn't manifest itself before, but it's clearly a bug, so here's a
fix. We should probably merge this before 0.14.
  • Loading branch information
pcwalton committed May 18, 2024
1 parent a55e0e3 commit 846757c
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions crates/bevy_pbr/src/render/pbr_prepass_functions.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ fn prepass_alpha_discard(in: VertexOutput) {
var output_color: vec4<f32> = pbr_bindings::material.base_color;

#ifdef VERTEX_UVS
#ifdef VERTEX_UVS_A
var uv = in.uv;
#else
#ifdef STANDARD_MATERIAL_BASE_COLOR_UV_B
var uv = in.uv_b;
#endif
#ifdef VERTEX_UVS_B
if ((pbr_bindings::material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_BASE_COLOR_UV_BIT) != 0u) {
uv = in.uv_b;
}
#endif
#else // STANDARD_MATERIAL_BASE_COLOR_UV_B
var uv = in.uv;
#endif // STANDARD_MATERIAL_BASE_COLOR_UV_B

let uv_transform = pbr_bindings::material.uv_transform;
uv = (uv_transform * vec3(uv, 1.0)).xy;
if (pbr_bindings::material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_BASE_COLOR_TEXTURE_BIT) != 0u {
Expand Down

0 comments on commit 846757c

Please sign in to comment.