From f71dc5daebb82fd6a5bfbd0e8f927238232bc4e2 Mon Sep 17 00:00:00 2001 From: Patrik Buhring Date: Thu, 31 Dec 2020 17:51:21 -0500 Subject: [PATCH] Fix potential bug when using multiple lights. (#1055) --- .../bevy_pbr/src/render_graph/forward_pipeline/forward.frag | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/bevy_pbr/src/render_graph/forward_pipeline/forward.frag b/crates/bevy_pbr/src/render_graph/forward_pipeline/forward.frag index 0b8242a98d410..c523b052fd44a 100644 --- a/crates/bevy_pbr/src/render_graph/forward_pipeline/forward.frag +++ b/crates/bevy_pbr/src/render_graph/forward_pipeline/forward.frag @@ -53,6 +53,10 @@ void main() { // add light contribution color += diffuse * light.color.xyz; } + + // average the lights so that we will never get something with > 1.0 + color /= max(float(NumLights.x), 1.0); + output_color.xyz *= color; # endif