11export default `
22
3- uniform sampler2D positions ;
4- uniform sampler2D normals ;
5- uniform sampler2D uvs ;
6- uniform sampler2D bvh ;
3+ uniform sampler2D positionBuffer ;
4+ uniform sampler2D normalBuffer ;
5+ uniform sampler2D uvBuffer ;
6+ uniform sampler2D bvhBuffer ;
77
88struct Triangle {
99 vec3 p0;
@@ -19,15 +19,15 @@ void surfaceInteractionFromBVH(inout SurfaceInteraction si, Triangle tri, vec3 b
1919 ivec2 i1 = unpackTexel(index.y, VERTEX_COLUMNS);
2020 ivec2 i2 = unpackTexel(index.z, VERTEX_COLUMNS);
2121
22- vec3 n0 = texelFetch(normals , i0, 0 ).xyz;
23- vec3 n1 = texelFetch(normals , i1, 0 ).xyz;
24- vec3 n2 = texelFetch(normals , i2, 0 ).xyz;
22+ vec3 n0 = texelFetch(normalBuffer , i0, 0 ).xyz;
23+ vec3 n1 = texelFetch(normalBuffer , i1, 0 ).xyz;
24+ vec3 n2 = texelFetch(normalBuffer , i2, 0 ).xyz;
2525 vec3 normal = normalize (barycentric.x * n0 + barycentric.y * n1 + barycentric.z * n2);
2626
2727 #if defined(NUM_DIFFUSE_MAPS) || defined(NUM_NORMAL_MAPS) || defined(NUM_PBR_MAPS)
28- vec2 uv0 = texelFetch(uvs , i0, 0 ).xy;
29- vec2 uv1 = texelFetch(uvs , i1, 0 ).xy;
30- vec2 uv2 = texelFetch(uvs , i2, 0 ).xy;
28+ vec2 uv0 = texelFetch(uvBuffer , i0, 0 ).xy;
29+ vec2 uv1 = texelFetch(uvBuffer , i1, 0 ).xy;
30+ vec2 uv2 = texelFetch(uvBuffer , i2, 0 ).xy;
3131 vec2 uv = fract (barycentric.x * uv0 + barycentric.y * uv1 + barycentric.z * uv2);
3232 #else
3333 vec2 uv = vec2 (0.0 );
@@ -170,8 +170,8 @@ void intersectScene(inout Ray ray, inout SurfaceInteraction si) {
170170 while (stack >= 0 ) {
171171 int i = nodesToVisit[stack-- ];
172172
173- vec4 r1 = fetchData(bvh , i, BVH_COLUMNS);
174- vec4 r2 = fetchData(bvh , i + 1 , BVH_COLUMNS);
173+ vec4 r1 = fetchData(bvhBuffer , i, BVH_COLUMNS);
174+ vec4 r2 = fetchData(bvhBuffer , i + 1 , BVH_COLUMNS);
175175
176176 int splitAxisOrNumPrimitives = floatBitsToInt(r1.w);
177177
@@ -194,9 +194,9 @@ void intersectScene(inout Ray ray, inout SurfaceInteraction si) {
194194 } else {
195195 ivec3 index = floatBitsToInt(r1.xyz);
196196 Triangle tri = Triangle(
197- fetchData(positions , index.x, VERTEX_COLUMNS).xyz,
198- fetchData(positions , index.y, VERTEX_COLUMNS).xyz,
199- fetchData(positions , index.z, VERTEX_COLUMNS).xyz
197+ fetchData(positionBuffer , index.x, VERTEX_COLUMNS).xyz,
198+ fetchData(positionBuffer , index.y, VERTEX_COLUMNS).xyz,
199+ fetchData(positionBuffer , index.z, VERTEX_COLUMNS).xyz
200200 );
201201 TriangleIntersect hit = intersectTriangle(ray, tri, maxDim, shear);
202202
@@ -236,8 +236,8 @@ bool intersectSceneShadow(inout Ray ray) {
236236 while (stack >= 0 ) {
237237 int i = nodesToVisit[stack-- ];
238238
239- vec4 r1 = fetchData(bvh , i, BVH_COLUMNS);
240- vec4 r2 = fetchData(bvh , i + 1 , BVH_COLUMNS);
239+ vec4 r1 = fetchData(bvhBuffer , i, BVH_COLUMNS);
240+ vec4 r2 = fetchData(bvhBuffer , i + 1 , BVH_COLUMNS);
241241
242242 int splitAxisOrNumPrimitives = floatBitsToInt(r1.w);
243243
@@ -258,9 +258,9 @@ bool intersectSceneShadow(inout Ray ray) {
258258 } else {
259259 ivec3 index = floatBitsToInt(r1.xyz);
260260 Triangle tri = Triangle(
261- fetchData(positions , index.x, VERTEX_COLUMNS).xyz,
262- fetchData(positions , index.y, VERTEX_COLUMNS).xyz,
263- fetchData(positions , index.z, VERTEX_COLUMNS).xyz
261+ fetchData(positionBuffer , index.x, VERTEX_COLUMNS).xyz,
262+ fetchData(positionBuffer , index.y, VERTEX_COLUMNS).xyz,
263+ fetchData(positionBuffer , index.z, VERTEX_COLUMNS).xyz
264264 );
265265
266266 if (intersectTriangle(ray, tri, maxDim, shear).t > 0.0 ) {
0 commit comments