@@ -59911,7 +59911,7 @@ var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying flo
5991159911
5991259912var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}";
5991359913
59914- var light_probe_volume_pars_fragment = "#ifdef USE_LIGHT_PROBE_VOLUME\nuniform highp sampler3D probeGridSH;\nuniform vec3 probeGridMin;\nuniform vec3 probeGridMax;\nuniform vec3 probeGridResolution;\nvec3 getLightProbeVolumeIrradiance( vec3 worldPos, vec3 worldNormal ) {\n\tvec3 res = probeGridResolution;\n\tvec3 gridRange = probeGridMax - probeGridMin;\n\tvec3 resMinusOne = res - 1.0;\n\tvec3 probeSpacing = gridRange / resMinusOne;\n\tvec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n\tvec3 uvw = clamp( ( samplePos - probeGridMin ) / gridRange, 0.0, 1.0 );\n\tuvw = uvw * resMinusOne / res + 0.5 / res;\n\tfloat nz = res.z;\n\tfloat paddedSlices = nz + 2.0;\n\tfloat atlasDepth = 7.0 * paddedSlices;\n\tfloat uvZBase = uvw.z * nz + 1.0;\n\tvec4 s0 = texture( probeGridSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n\tvec4 s1 = texture( probeGridSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n\tvec4 s2 = texture( probeGridSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s3 = texture( probeGridSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s4 = texture( probeGridSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s5 = texture( probeGridSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n\tvec4 s6 = texture( probeGridSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n\tvec3 c0 = s0.xyz;\n\tvec3 c1 = vec3( s0.w, s1.xy );\n\tvec3 c2 = vec3( s1.zw, s2.x );\n\tvec3 c3 = s2.yzw;\n\tvec3 c4 = s3.xyz;\n\tvec3 c5 = vec3( s3.w, s4.xy );\n\tvec3 c6 = vec3( s4.zw, s5.x );\n\tvec3 c7 = s5.yzw;\n\tvec3 c8 = s6.xyz;\n\tfloat x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n\tvec3 result = c0 * 0.886227;\n\tresult += c1 * 2.0 * 0.511664 * y;\n\tresult += c2 * 2.0 * 0.511664 * z;\n\tresult += c3 * 2.0 * 0.511664 * x;\n\tresult += c4 * 2.0 * 0.429043 * x * y;\n\tresult += c5 * 2.0 * 0.429043 * y * z;\n\tresult += c6 * ( 0.743125 * z * z - 0.247708 );\n\tresult += c7 * 2.0 * 0.429043 * x * z;\n\tresult += c8 * 0.429043 * ( x * x - y * y );\n\treturn max( result, vec3( 0.0 ) );\n}\n#endif";
59914+ var light_probe_volume_pars_fragment = "#ifdef USE_LIGHT_PROBE_VOLUME\nuniform highp sampler3D probeGridSH0;\nuniform highp sampler3D probeGridSH1;\nuniform highp sampler3D probeGridSH2;\nuniform highp sampler3D probeGridSH3;\nuniform highp sampler3D probeGridSH4;\nuniform highp sampler3D probeGridSH5;\nuniform highp sampler3D probeGridSH6;\nuniform vec3 probeGridMin;\nuniform vec3 probeGridMax;\nvec3 getLightProbeVolumeIrradiance( vec3 worldPos, vec3 worldNormal ) {\n\tvec3 texSize = vec3( textureSize( probeGridSH0, 0 ) );\n\tvec3 texSizeMinusOne = texSize - 1.0;\n\tvec3 gridRange = probeGridMax - probeGridMin;\n\tvec3 probeSpacing = gridRange / texSizeMinusOne;\n\tvec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n\tvec3 uvw = clamp( ( samplePos - probeGridMin ) / gridRange, 0.0, 1.0 );\n\tuvw = uvw * texSizeMinusOne / texSize + 0.5 / texSize;\n\tvec4 s0 = texture( probeGridSH0, uvw );\n\tvec4 s1 = texture( probeGridSH1, uvw );\n\tvec4 s2 = texture( probeGridSH2, uvw );\n\tvec4 s3 = texture( probeGridSH3, uvw );\n\tvec4 s4 = texture( probeGridSH4, uvw );\n\tvec4 s5 = texture( probeGridSH5, uvw );\n\tvec4 s6 = texture( probeGridSH6, uvw );\n\tvec3 c0 = s0.xyz;\n\tvec3 c1 = vec3( s0.w, s1.xy );\n\tvec3 c2 = vec3( s1.zw, s2.x );\n\tvec3 c3 = s2.yzw;\n\tvec3 c4 = s3.xyz;\n\tvec3 c5 = vec3( s3.w, s4.xy );\n\tvec3 c6 = vec3( s4.zw, s5.x );\n\tvec3 c7 = s5.yzw;\n\tvec3 c8 = s6.xyz;\n\tfloat x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n\tvec3 result = c0 * 0.886227;\n\tresult += c1 * 2.0 * 0.511664 * y;\n\tresult += c2 * 2.0 * 0.511664 * z;\n\tresult += c3 * 2.0 * 0.511664 * x;\n\tresult += c4 * 2.0 * 0.429043 * x * y;\n\tresult += c5 * 2.0 * 0.429043 * y * z;\n\tresult += c6 * ( 0.743125 * z * z - 0.247708 );\n\tresult += c7 * 2.0 * 0.429043 * x * z;\n\tresult += c8 * 0.429043 * ( x * x - y * y );\n\treturn max( result, vec3( 0.0 ) );\n}\n#endif";
5991559915
5991659916var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif";
5991759917
@@ -60448,10 +60448,15 @@ const UniformsLib = {
6044860448 ltc_1: { value: null },
6044960449 ltc_2: { value: null },
6045060450
60451- probeGridSH: { value: null },
60451+ probeGridSH0: { value: null },
60452+ probeGridSH1: { value: null },
60453+ probeGridSH2: { value: null },
60454+ probeGridSH3: { value: null },
60455+ probeGridSH4: { value: null },
60456+ probeGridSH5: { value: null },
60457+ probeGridSH6: { value: null },
6045260458 probeGridMin: { value: /*@__PURE__*/ new Vector3() },
60453- probeGridMax: { value: /*@__PURE__*/ new Vector3() },
60454- probeGridResolution: { value: /*@__PURE__*/ new Vector3() }
60459+ probeGridMax: { value: /*@__PURE__*/ new Vector3() }
6045560460
6045660461 },
6045760462
@@ -75417,6 +75422,32 @@ function getDFGLUT() {
7541775422
7541875423}
7541975424
75425+ const _objectPosition = /*@__PURE__*/ new Vector3();
75426+
75427+ function findLightProbeVolume( volumes, object ) {
75428+
75429+ if ( volumes.length === 0 ) return null;
75430+
75431+ if ( volumes.length === 1 ) {
75432+
75433+ return volumes[ 0 ].textures[ 0 ] !== null ? volumes[ 0 ] : null;
75434+
75435+ }
75436+
75437+ _objectPosition.setFromMatrixPosition( object.matrixWorld );
75438+
75439+ for ( let i = 0, l = volumes.length; i < l; i ++ ) {
75440+
75441+ const v = volumes[ i ];
75442+
75443+ if ( v.textures[ 0 ] !== null && v.boundingBox.containsPoint( _objectPosition ) ) return v;
75444+
75445+ }
75446+
75447+ return null;
75448+
75449+ }
75450+
7542075451/**
7542175452 * This renderer uses WebGL 2 to display scenes.
7542275453 *
@@ -75492,7 +75523,6 @@ class WebGLRenderer {
7549275523
7549375524 const uintClearColor = new Uint32Array( 4 );
7549475525 const intClearColor = new Int32Array( 4 );
75495- const objectPosition = new Vector3();
7549675526
7549775527 let currentRenderList = null;
7549875528 let currentRenderState = null;
@@ -77632,30 +77662,6 @@ class WebGLRenderer {
7763277662
7763377663 }
7763477664
77635- function findLightProbeVolume( volumes, object ) {
77636-
77637- if ( volumes.length === 0 ) return null;
77638-
77639- if ( volumes.length === 1 ) {
77640-
77641- return volumes[ 0 ].texture !== null ? volumes[ 0 ] : null;
77642-
77643- }
77644-
77645- objectPosition.setFromMatrixPosition( object.matrixWorld );
77646-
77647- for ( let i = 0, l = volumes.length; i < l; i ++ ) {
77648-
77649- const v = volumes[ i ];
77650-
77651- if ( v.texture !== null && v.boundingBox.containsPoint( objectPosition ) ) return v;
77652-
77653- }
77654-
77655- return null;
77656-
77657- }
77658-
7765977665 function setProgram( camera, scene, geometry, material, object ) {
7766077666
7766177667 if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...
@@ -77862,9 +77868,9 @@ class WebGLRenderer {
7786277868
7786377869 const objectVolume = findLightProbeVolume( currentRenderState.state.lightProbeVolumesArray, object );
7786477870
77865- if ( materialProperties.lightProbeVolume !== objectVolume ) {
77871+ if ( materialProperties.__lightProbeVolume !== objectVolume ) {
7786677872
77867- materialProperties.lightProbeVolume = objectVolume;
77873+ materialProperties.__lightProbeVolume = objectVolume;
7786877874 refreshMaterial = true;
7786977875
7787077876 }
@@ -78050,16 +78056,21 @@ class WebGLRenderer {
7805078056
7805178057 materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget[ camera.id ] );
7805278058
78053- // light probe volume
78059+ // irradiance probe grid
7805478060
78055- if ( materialProperties.needsLights && materialProperties.lightProbeVolume ) {
78061+ if ( materialProperties.needsLights && materialProperties.__lightProbeVolume ) {
7805678062
78057- const volume = materialProperties.lightProbeVolume ;
78063+ const volume = materialProperties.__lightProbeVolume ;
7805878064
78059- m_uniforms.probeGridSH.value = volume.texture;
78065+ m_uniforms.probeGridSH0.value = volume.textures[ 0 ];
78066+ m_uniforms.probeGridSH1.value = volume.textures[ 1 ];
78067+ m_uniforms.probeGridSH2.value = volume.textures[ 2 ];
78068+ m_uniforms.probeGridSH3.value = volume.textures[ 3 ];
78069+ m_uniforms.probeGridSH4.value = volume.textures[ 4 ];
78070+ m_uniforms.probeGridSH5.value = volume.textures[ 5 ];
78071+ m_uniforms.probeGridSH6.value = volume.textures[ 6 ];
7806078072 m_uniforms.probeGridMin.value.copy( volume.boundingBox.min );
7806178073 m_uniforms.probeGridMax.value.copy( volume.boundingBox.max );
78062- m_uniforms.probeGridResolution.value.copy( volume.resolution );
7806378074
7806478075 }
7806578076
0 commit comments