@@ -380,7 +380,7 @@ ${ flowData.code }
380
380
/**
381
381
* Generates the GLSL snippet that reads a single texel from a texture without sampling or filtering.
382
382
*
383
- * @param {Texture } texture - The texture.
383
+ * @param {? Texture } texture - The texture.
384
384
* @param {string } textureProperty - The name of the texture uniform in the shader.
385
385
* @param {string } uvIndexSnippet - A GLSL snippet that represents texture coordinates used for sampling.
386
386
* @param {?string } depthSnippet - A GLSL snippet that represents the 0-based texture array index to sample.
@@ -390,28 +390,42 @@ ${ flowData.code }
390
390
*/
391
391
generateTextureLoad ( texture , textureProperty , uvIndexSnippet , depthSnippet , offsetSnippet , levelSnippet = '0' ) {
392
392
393
+ let snippet ;
394
+
393
395
if ( depthSnippet ) {
394
396
395
397
if ( offsetSnippet ) {
396
398
397
- return `texelFetchOffset( ${ textureProperty } , ivec3( ${ uvIndexSnippet } , ${ depthSnippet } ), ${ levelSnippet } , ${ offsetSnippet } )` ;
399
+ snippet = `texelFetchOffset( ${ textureProperty } , ivec3( ${ uvIndexSnippet } , ${ depthSnippet } ), ${ levelSnippet } , ${ offsetSnippet } )` ;
398
400
399
- }
401
+ } else {
400
402
401
- return `texelFetch( ${ textureProperty } , ivec3( ${ uvIndexSnippet } , ${ depthSnippet } ), ${ levelSnippet } )` ;
403
+ snippet = `texelFetch( ${ textureProperty } , ivec3( ${ uvIndexSnippet } , ${ depthSnippet } ), ${ levelSnippet } )` ;
404
+
405
+ }
402
406
403
407
} else {
404
408
405
409
if ( offsetSnippet ) {
406
410
407
- return `texelFetchOffset( ${ textureProperty } , ${ uvIndexSnippet } , ${ levelSnippet } , ${ offsetSnippet } )` ;
411
+ snippet = `texelFetchOffset( ${ textureProperty } , ${ uvIndexSnippet } , ${ levelSnippet } , ${ offsetSnippet } )` ;
412
+
413
+ } else {
414
+
415
+ snippet = `texelFetch( ${ textureProperty } , ${ uvIndexSnippet } , ${ levelSnippet } )` ;
408
416
409
417
}
410
418
411
- return `texelFetch( ${ textureProperty } , ${ uvIndexSnippet } , ${ levelSnippet } )` ;
419
+ }
420
+
421
+ if ( texture !== null && texture . isDepthTexture ) {
422
+
423
+ snippet += '.x' ;
412
424
413
425
}
414
426
427
+ return snippet ;
428
+
415
429
}
416
430
417
431
/**
0 commit comments