Skip to content

Commit 8a7848a

Browse files
WebGLUniforms: Assign compareFunction lazily to retain tree-shaking. (#28670)
* WebGLUniforms: lazily create shadow texture for tree-shaking * WebGLUniforms: lazily set compareFunction instead * Update WebGLUniforms.js Add comment --------- Co-authored-by: Michael Herzog <[email protected]>
1 parent af083e1 commit 8a7848a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/renderers/webgl/WebGLUniforms.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ import { LessEqualCompare } from '../../constants.js';
5151
const emptyTexture = /*@__PURE__*/ new Texture();
5252

5353
const emptyShadowTexture = /*@__PURE__*/ new DepthTexture( 1, 1 );
54-
emptyShadowTexture.compareFunction = LessEqualCompare;
5554

5655
const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture();
5756
const empty3dTexture = /*@__PURE__*/ new Data3DTexture();
@@ -569,7 +568,18 @@ function setValueT1( gl, v, textures ) {
569568

570569
}
571570

572-
const emptyTexture2D = ( this.type === gl.SAMPLER_2D_SHADOW ) ? emptyShadowTexture : emptyTexture;
571+
let emptyTexture2D = null;
572+
573+
if ( this.type === gl.SAMPLER_2D_SHADOW ) {
574+
575+
emptyShadowTexture.compareFunction = LessEqualCompare; // #28670
576+
emptyTexture2D = emptyShadowTexture;
577+
578+
} else {
579+
580+
emptyTexture2D = emptyTexture;
581+
582+
}
573583

574584
textures.setTexture2D( v || emptyTexture2D, unit );
575585

0 commit comments

Comments
 (0)