From 109612c7bc416d3ab45f30edbfc40a2ff7d090c4 Mon Sep 17 00:00:00 2001 From: netpro2k Date: Mon, 10 Jan 2022 19:41:31 -0800 Subject: [PATCH] Respect physicallyCorrectLights on lightmaps in MeshBasicMaterial --- src/renderers/shaders/ShaderLib/meshbasic.glsl.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/renderers/shaders/ShaderLib/meshbasic.glsl.js b/src/renderers/shaders/ShaderLib/meshbasic.glsl.js index 3cd936dafe63b2..dd126b286d6a12 100644 --- a/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +++ b/src/renderers/shaders/ShaderLib/meshbasic.glsl.js @@ -86,8 +86,17 @@ void main() { // accumulation (baked indirect lighting only) #ifdef USE_LIGHTMAP - vec4 lightMapTexel= texture2D( lightMap, vUv2 ); - reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity; + vec4 lightMapTexel = texture2D( lightMap, vUv2 ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + + // Lightmaps are the only source of "light" for basic materials, respect them being "phsyically correct" + #ifdef PHYSICALLY_CORRECT_LIGHTS + + lightMapIrradiance *= RECIPROCAL_PI; + + #endif + + reflectedLight.indirectDiffuse += lightMapIrradiance; #else