From b4d64ca5fb3d25385709b427dfcd8a9242fec78e Mon Sep 17 00:00:00 2001 From: WestLangley Date: Wed, 1 Apr 2020 22:17:56 -0400 Subject: [PATCH] Add support for LightProbes --- .../ShaderChunk/lights_lambert_vertex.glsl.js | 13 ++++++++++++- .../shaders/ShaderLib/meshlambert_frag.glsl.js | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js b/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js index 801d90d3ff0f28..67e658f1303de4 100644 --- a/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js +++ b/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js @@ -13,7 +13,6 @@ backGeometry.viewDir = geometry.viewDir; vLightFront = vec3( 0.0 ); vIndirectFront = vec3( 0.0 ); - #ifdef DOUBLE_SIDED vLightBack = vec3( 0.0 ); vIndirectBack = vec3( 0.0 ); @@ -23,6 +22,18 @@ IncidentLight directLight; float dotNL; vec3 directLightColor_Diffuse; +vIndirectFront += getAmbientLightIrradiance( ambientLightColor ); + +vIndirectFront += getLightProbeIrradiance( lightProbe, geometry ); + +#ifdef DOUBLE_SIDED + + vIndirectBack += getAmbientLightIrradiance( ambientLightColor ); + + vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry ); + +#endif + #if NUM_POINT_LIGHTS > 0 #pragma unroll_loop_start diff --git a/src/renderers/shaders/ShaderLib/meshlambert_frag.glsl.js b/src/renderers/shaders/ShaderLib/meshlambert_frag.glsl.js index ddb9bfce661651..6749e875349948 100644 --- a/src/renderers/shaders/ShaderLib/meshlambert_frag.glsl.js +++ b/src/renderers/shaders/ShaderLib/meshlambert_frag.glsl.js @@ -52,7 +52,6 @@ void main() { #include // accumulation - reflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor ); #ifdef DOUBLE_SIDED @@ -81,6 +80,7 @@ void main() { reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask(); // modulation + #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;