Skip to content

Commit 5823b1b

Browse files
RenaudRohlingermrdoob
authored andcommitted
WebGLUniforms: sampler2DShadow support (mrdoob#27252)
* add support for sampler2DShadow in uniforms * Update WebGLUniforms.js * use gl.SAMPLER_2D_SHADOW instead * Update WebGLUniforms.js --------- Co-authored-by: mrdoob <[email protected]>
1 parent fb3ba71 commit 5823b1b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/renderers/webgl/WebGLUniforms.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ import { CubeTexture } from '../../textures/CubeTexture.js';
4545
import { Texture } from '../../textures/Texture.js';
4646
import { DataArrayTexture } from '../../textures/DataArrayTexture.js';
4747
import { Data3DTexture } from '../../textures/Data3DTexture.js';
48+
import { DepthTexture } from '../../textures/DepthTexture.js';
49+
import { LessEqualCompare } from '../../constants.js';
4850

4951
const emptyTexture = /*@__PURE__*/ new Texture();
52+
53+
const emptyShadowTexture = /*@__PURE__*/ new DepthTexture( 1, 1 );
54+
emptyShadowTexture.compareFunction = LessEqualCompare;
55+
5056
const emptyArrayTexture = /*@__PURE__*/ new DataArrayTexture();
5157
const empty3dTexture = /*@__PURE__*/ new Data3DTexture();
5258
const emptyCubeTexture = /*@__PURE__*/ new CubeTexture();
@@ -563,7 +569,9 @@ function setValueT1( gl, v, textures ) {
563569

564570
}
565571

566-
textures.setTexture2D( v || emptyTexture, unit );
572+
const emptyTexture2D = ( this.type === gl.SAMPLER_2D_SHADOW ) ? emptyShadowTexture : emptyTexture;
573+
574+
textures.setTexture2D( v || emptyTexture2D, unit );
567575

568576
}
569577

@@ -947,6 +955,7 @@ class SingleUniform {
947955
this.id = id;
948956
this.addr = addr;
949957
this.cache = [];
958+
this.type = activeInfo.type;
950959
this.setValue = getSingularSetter( activeInfo.type );
951960

952961
// this.path = activeInfo.name; // DEBUG
@@ -962,6 +971,7 @@ class PureArrayUniform {
962971
this.id = id;
963972
this.addr = addr;
964973
this.cache = [];
974+
this.type = activeInfo.type;
965975
this.size = activeInfo.size;
966976
this.setValue = getPureArraySetter( activeInfo.type );
967977

0 commit comments

Comments
 (0)