From a1879efbe3445f4f878d34c83f9e58cec7b913e8 Mon Sep 17 00:00:00 2001 From: Patrik Buhring Date: Sun, 13 Dec 2020 13:46:33 -0500 Subject: [PATCH] Fix potential bug when using multiple lights. --- .../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