From fdf2f56f4d07d98988977d7134a841bd518d281a Mon Sep 17 00:00:00 2001 From: WestLangley Date: Mon, 23 Aug 2021 14:02:35 -0400 Subject: [PATCH] honor the physicallyCorrectLights flag when using a light map --- .../shaders/ShaderChunk/lightmap_fragment.glsl.js | 12 ++++++++++-- .../shaders/ShaderChunk/lights_fragment_maps.glsl.js | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js b/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js index 70ddaa6e27bfed..2a8a907cfc26cf 100644 --- a/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +++ b/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js @@ -1,8 +1,16 @@ export default /* glsl */` #ifdef USE_LIGHTMAP - vec4 lightMapTexel= texture2D( lightMap, vUv2 ); - reflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; // factor of PI should not be present; included here to prevent breakage + vec4 lightMapTexel = texture2D( lightMap, vUv2 ); + vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; + + #ifndef PHYSICALLY_CORRECT_LIGHTS + + lightMapIrradiance *= PI; + + #endif + + reflectedLight.indirectDiffuse += lightMapIrradiance; #endif `; diff --git a/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js b/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js index 0e11b3584a62a1..74bca05e67d81e 100644 --- a/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +++ b/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js @@ -3,12 +3,12 @@ export default /* glsl */` #ifdef USE_LIGHTMAP - vec4 lightMapTexel= texture2D( lightMap, vUv2 ); + vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; #ifndef PHYSICALLY_CORRECT_LIGHTS - lightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage + lightMapIrradiance *= PI; #endif