Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ backGeometry.normal = -geometry.normal;
backGeometry.viewDir = geometry.viewDir;

vLightFront = vec3( 0.0 );
vIndirectFront = vec3( 0.0 );

#ifdef DOUBLE_SIDED
vLightBack = vec3( 0.0 );
vIndirectBack = vec3( 0.0 );
#endif

IncidentLight directLight;
Expand Down Expand Up @@ -103,11 +105,11 @@ vec3 directLightColor_Diffuse;
#pragma unroll_loop
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {

vLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );

#ifdef DOUBLE_SIDED

vLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );
vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );

#endif

Expand Down
16 changes: 13 additions & 3 deletions src/renderers/shaders/ShaderLib/meshlambert_frag.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ uniform vec3 emissive;
uniform float opacity;

varying vec3 vLightFront;
varying vec3 vIndirectFront;

#ifdef DOUBLE_SIDED

varying vec3 vLightBack;

varying vec3 vIndirectBack;
#endif


#include <common>
#include <packing>
#include <dithering_pars_fragment>
Expand Down Expand Up @@ -51,6 +52,16 @@ void main() {
// accumulation
reflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );

#ifdef DOUBLE_SIDED

reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;

#else

reflectedLight.indirectDiffuse += vIndirectFront;

#endif

#include <lightmap_fragment>

reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );
Expand Down Expand Up @@ -81,6 +92,5 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>

}
`;
5 changes: 2 additions & 3 deletions src/renderers/shaders/ShaderLib/meshlambert_vert.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ export default /* glsl */`
#define LAMBERT

varying vec3 vLightFront;
varying vec3 vIndirectFront;

#ifdef DOUBLE_SIDED

varying vec3 vLightBack;

varying vec3 vIndirectBack;
#endif

#include <common>
Expand Down Expand Up @@ -47,6 +47,5 @@ void main() {
#include <lights_lambert_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>

}
`;