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
6 changes: 5 additions & 1 deletion examples/jsm/csm/CSMShader.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ IncidentLight directLight;

vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );

irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
#if defined( USE_LIGHT_PROBES )

irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );

#endif

#if ( NUM_HEMI_LIGHTS > 0 )

Expand Down
12 changes: 10 additions & 2 deletions examples/jsm/materials/MeshGouraudMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,21 @@ const GouraudShader = {

vIndirectFront += getAmbientLightIrradiance( ambientLightColor );

vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
#if defined( USE_LIGHT_PROBES )

vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );

#endif

#ifdef DOUBLE_SIDED

vIndirectBack += getAmbientLightIrradiance( ambientLightColor );

vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
#if defined( USE_LIGHT_PROBES )

vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );

#endif

#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ IncidentLight directLight;

vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );

irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
#if defined( USE_LIGHT_PROBES )

irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );

#endif

#if ( NUM_HEMI_LIGHTS > 0 )

Expand Down
7 changes: 6 additions & 1 deletion src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
export default /* glsl */`
uniform bool receiveShadow;
uniform vec3 ambientLightColor;
uniform vec3 lightProbe[ 9 ];

#if defined( USE_LIGHT_PROBES )

uniform vec3 lightProbe[ 9 ];

#endif

// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere
// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf
Expand Down
17 changes: 14 additions & 3 deletions src/renderers/webgl/WebGLLights.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ function WebGLLights( extensions, capabilities ) {
numDirectionalShadows: - 1,
numPointShadows: - 1,
numSpotShadows: - 1,
numSpotMaps: - 1
numSpotMaps: - 1,

numLightProbes: - 1
},

ambient: [ 0, 0, 0 ],
Expand All @@ -192,7 +194,8 @@ function WebGLLights( extensions, capabilities ) {
pointShadowMap: [],
pointShadowMatrix: [],
hemi: [],
numSpotLightShadowsWithMaps: 0
numSpotLightShadowsWithMaps: 0,
numLightProbes: 0

};

Expand Down Expand Up @@ -220,6 +223,8 @@ function WebGLLights( extensions, capabilities ) {
let numSpotMaps = 0;
let numSpotShadowsWithMaps = 0;

let numLightProbes = 0;

// ordering : [shadow casting + map texturing, map texturing, shadow casting, none ]
lights.sort( shadowCastingAndTexturingLightsFirst );

Expand Down Expand Up @@ -250,6 +255,8 @@ function WebGLLights( extensions, capabilities ) {

}

numLightProbes ++;

} else if ( light.isDirectionalLight ) {

const uniforms = cache.get( light );
Expand Down Expand Up @@ -437,7 +444,8 @@ function WebGLLights( extensions, capabilities ) {
hash.numDirectionalShadows !== numDirectionalShadows ||
hash.numPointShadows !== numPointShadows ||
hash.numSpotShadows !== numSpotShadows ||
hash.numSpotMaps !== numSpotMaps ) {
hash.numSpotMaps !== numSpotMaps ||
hash.numLightProbes !== numLightProbes ) {

state.directional.length = directionalLength;
state.spot.length = spotLength;
Expand All @@ -456,6 +464,7 @@ function WebGLLights( extensions, capabilities ) {
state.spotLightMatrix.length = numSpotShadows + numSpotMaps - numSpotShadowsWithMaps;
state.spotLightMap.length = numSpotMaps;
state.numSpotLightShadowsWithMaps = numSpotShadowsWithMaps;
state.numLightProbes = numLightProbes;

hash.directionalLength = directionalLength;
hash.pointLength = pointLength;
Expand All @@ -468,6 +477,8 @@ function WebGLLights( extensions, capabilities ) {
hash.numSpotShadows = numSpotShadows;
hash.numSpotMaps = numSpotMaps;

hash.numLightProbes = numLightProbes;

state.version = nextVersion ++;

}
Expand Down
4 changes: 4 additions & 0 deletions src/renderers/webgl/WebGLProgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {

parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '',

parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',

parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',

parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
Expand Down Expand Up @@ -788,6 +790,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {

parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '',

parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',

parameters.useLegacyLights ? '#define LEGACY_LIGHTS' : '',

parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
Expand Down
3 changes: 3 additions & 0 deletions src/renderers/webgl/WebGLPrograms.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
numSpotLightShadows: lights.spotShadowMap.length,
numSpotLightShadowsWithMaps: lights.numSpotLightShadowsWithMaps,

numLightProbes: lights.numLightProbes,

numClippingPlanes: clipping.numPlanes,
numClipIntersection: clipping.numIntersection,

Expand Down Expand Up @@ -449,6 +451,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
array.push( parameters.numPointLightShadows );
array.push( parameters.numSpotLightShadows );
array.push( parameters.numSpotLightShadowsWithMaps );
array.push( parameters.numLightProbes );
array.push( parameters.shadowMapType );
array.push( parameters.toneMapping );
array.push( parameters.numClippingPlanes );
Expand Down