Skip to content

Commit 25db2d5

Browse files
committed
Add sampler array texel fetch
1 parent de3a463 commit 25db2d5

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/materials/PhysicalPathTracingMaterial.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export class PhysicalPathTracingMaterial extends MaterialBase {
4141
// 1 = Orthographic
4242
// 2 = Equirectangular
4343
CAMERA_TYPE: 0,
44+
45+
ATTR_NORMAL: 0,
46+
ATTR_TANGENT: 1,
47+
ATTR_UV: 2,
48+
ATTR_COLOR: 3,
4449
},
4550

4651
uniforms: {

src/shader/shaderUtils.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,25 @@ export const shaderUtils = /* glsl */`
361361
362362
}
363363
364+
// add texel fetch functions for texture arrays
365+
vec4 texelFetch1D( sampler2DArray tex, int layer, uint index ) {
366+
367+
uint width = uint( textureSize( tex, 0 ).x );
368+
uvec2 uv;
369+
uv.x = index % width;
370+
uv.y = index / width;
371+
372+
return texelFetch( tex, ivec3( uv, layer ), 0 );
373+
374+
}
375+
376+
vec4 textureSampleBarycoord( sampler2DArray tex, int layer, vec3 barycoord, vec3 faceIndices ) {
377+
378+
return
379+
barycoord.x * texelFetch1D( tex, layer, faceIndices.x ) +
380+
barycoord.y * texelFetch1D( tex, layer, faceIndices.y ) +
381+
barycoord.z * texelFetch1D( tex, layer, faceIndices.z );
382+
383+
}
384+
364385
`;

0 commit comments

Comments
 (0)