From f3d4be316d270177785471916d506b2507a1b252 Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Fri, 26 Nov 2021 13:16:11 +0000 Subject: [PATCH] bevy_pbr2: Fix shadow logic (#3186) # Objective - Shadow maps should only be sampled if the mesh is a shadow receiver AND shadow mapping is enabled for the light ## Solution - Fix the logic in the shader --- pipelined/bevy_pbr2/src/render/pbr.wgsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipelined/bevy_pbr2/src/render/pbr.wgsl b/pipelined/bevy_pbr2/src/render/pbr.wgsl index bb5515657a..45e6fc2a92 100644 --- a/pipelined/bevy_pbr2/src/render/pbr.wgsl +++ b/pipelined/bevy_pbr2/src/render/pbr.wgsl @@ -501,7 +501,7 @@ fn fragment(in: FragmentInput) -> [[location(0)]] vec4 { let light = lights.point_lights[i]; var shadow: f32; if ((mesh.flags & MESH_FLAGS_SHADOW_RECEIVER_BIT) != 0u - || (light.flags & POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) { + && (light.flags & POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) { shadow = fetch_point_shadow(i, in.world_position, in.world_normal); } else { shadow = 1.0; @@ -513,7 +513,7 @@ fn fragment(in: FragmentInput) -> [[location(0)]] vec4 { let light = lights.directional_lights[i]; var shadow: f32; if ((mesh.flags & MESH_FLAGS_SHADOW_RECEIVER_BIT) != 0u - || (light.flags & DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) { + && (light.flags & DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) { shadow = fetch_directional_shadow(i, in.world_position, in.world_normal); } else { shadow = 1.0;