Skip to content

Commit f3d4be3

Browse files
committed
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
1 parent 73fd6a6 commit f3d4be3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pipelined/bevy_pbr2/src/render/pbr.wgsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ fn fragment(in: FragmentInput) -> [[location(0)]] vec4<f32> {
501501
let light = lights.point_lights[i];
502502
var shadow: f32;
503503
if ((mesh.flags & MESH_FLAGS_SHADOW_RECEIVER_BIT) != 0u
504-
|| (light.flags & POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
504+
&& (light.flags & POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
505505
shadow = fetch_point_shadow(i, in.world_position, in.world_normal);
506506
} else {
507507
shadow = 1.0;
@@ -513,7 +513,7 @@ fn fragment(in: FragmentInput) -> [[location(0)]] vec4<f32> {
513513
let light = lights.directional_lights[i];
514514
var shadow: f32;
515515
if ((mesh.flags & MESH_FLAGS_SHADOW_RECEIVER_BIT) != 0u
516-
|| (light.flags & DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
516+
&& (light.flags & DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
517517
shadow = fetch_directional_shadow(i, in.world_position, in.world_normal);
518518
} else {
519519
shadow = 1.0;

0 commit comments

Comments
 (0)