Skip to content

Commit 4d69cdc

Browse files
authored
GLSLNodeBuilder: Fix texture() code generation for depth texture (#31770)
* Fix texture() code generation * Simplify conditionals
1 parent cf60b96 commit 4d69cdc

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -457,31 +457,19 @@ ${ flowData.code }
457457
*/
458458
generateTexture( texture, textureProperty, uvSnippet, depthSnippet, offsetSnippet ) {
459459

460-
if ( texture.isDepthTexture ) {
461-
462-
if ( depthSnippet ) uvSnippet = `vec4( ${ uvSnippet }, ${ depthSnippet } )`;
463-
464-
if ( offsetSnippet ) {
460+
if ( depthSnippet ) uvSnippet = `vec3( ${ uvSnippet }, ${ depthSnippet } )`;
465461

466-
return `textureOffset( ${ textureProperty }, ${ uvSnippet }, ${ offsetSnippet } ).x`;
462+
if ( texture.isDepthTexture ) {
467463

468-
}
464+
if ( offsetSnippet ) return `textureOffset( ${ textureProperty }, ${ uvSnippet }, ${ offsetSnippet } ).x`;
469465

470466
return `texture( ${ textureProperty }, ${ uvSnippet } ).x`;
471467

472-
} else {
473-
474-
if ( depthSnippet ) uvSnippet = `vec3( ${ uvSnippet }, ${ depthSnippet } )`;
475-
476-
if ( offsetSnippet ) {
477-
478-
return `textureOffset( ${ textureProperty }, ${ uvSnippet }, ${ offsetSnippet } )`;
479-
480-
}
468+
}
481469

482-
return `texture( ${ textureProperty }, ${ uvSnippet } )`;
470+
if ( offsetSnippet ) return `textureOffset( ${ textureProperty }, ${ uvSnippet }, ${ offsetSnippet } )`;
483471

484-
}
472+
return `texture( ${ textureProperty }, ${ uvSnippet } )`;
485473

486474
}
487475

0 commit comments

Comments
 (0)