Skip to content

Commit 5bab962

Browse files
aardgooseaardgoose
and
aardgoose
authored
WebGPURenderer: Support textureCompare() operations in WebGL backend (#26823)
Co-authored-by: aardgoose <[email protected]>
1 parent ac901f1 commit 5bab962

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js

+24-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ class GLSLNodeBuilder extends NodeBuilder {
6262

6363
}
6464

65+
getTextureCompare( texture, textureProperty, uvSnippet, compareSnippet, shaderStage = this.shaderStage ) {
66+
67+
if ( shaderStage === 'fragment' ) {
68+
69+
return `texture( ${textureProperty}, vec3( ${uvSnippet}, ${compareSnippet} ) )`;
70+
71+
} else {
72+
73+
console.error( `WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${ shaderStage } shader.` );
74+
75+
}
76+
77+
}
78+
6579
getVars( shaderStage ) {
6680

6781
const snippets = [];
@@ -94,7 +108,15 @@ class GLSLNodeBuilder extends NodeBuilder {
94108

95109
if ( uniform.type === 'texture' ) {
96110

97-
snippet = `sampler2D ${uniform.name};`;
111+
if ( uniform.node.value.compareFunction ) {
112+
113+
snippet = `sampler2DShadow ${uniform.name};`;
114+
115+
} else {
116+
117+
snippet = `sampler2D ${uniform.name};`;
118+
119+
}
98120

99121
} else if ( uniform.type === 'cubeTexture' ) {
100122

@@ -324,6 +346,7 @@ ${ this.getSignature() }
324346
// precision
325347
precision highp float;
326348
precision highp int;
349+
precision lowp sampler2DShadow;
327350
328351
// uniforms
329352
${shaderData.uniforms}

0 commit comments

Comments
 (0)