@@ -117,15 +117,17 @@ vec3 nbl_glsl_MC_getNormalizedWorldSpaceN()
117
117
118
118
#include < nbl/ builtin/ glsl/ barycentric/ utils.glsl>
119
119
mat2x3 dPdBary;
120
- vec3 load_positions(in uvec3 indices, in uint batchInstanceGUID )
120
+ vec3 load_positions(in uvec3 indices, in nbl_glsl_ext_Mitsuba_Loader_instance_data_t batchInstanceData )
121
121
{
122
- const mat3 positions = mat3 (
123
- nbl_glsl_fetchVtxPos(indices[0 ],batchInstanceGUID ),
124
- nbl_glsl_fetchVtxPos(indices[1 ],batchInstanceGUID ),
125
- nbl_glsl_fetchVtxPos(indices[2 ],batchInstanceGUID )
122
+ mat3 positions = mat3 (
123
+ nbl_glsl_fetchVtxPos(indices[0 ],batchInstanceData ),
124
+ nbl_glsl_fetchVtxPos(indices[1 ],batchInstanceData ),
125
+ nbl_glsl_fetchVtxPos(indices[2 ],batchInstanceData )
126
126
);
127
+ const mat4x3 tform = batchInstanceData.tform;
128
+ positions = mat3 (tform)* positions;
127
129
dPdBary = mat2x3 (positions[0 ]- positions[2 ],positions[1 ]- positions[2 ]);
128
- return positions[2 ];
130
+ return positions[2 ]+ tform[ 3 ] ;
129
131
}
130
132
#ifdef TEX_PREFETCH_STREAM
131
133
mat2x3 nbl_glsl_perturbNormal_dPdSomething()
@@ -161,13 +163,13 @@ void gen_sample_ray(
161
163
162
164
float pdf;
163
165
nbl_glsl_LightSample s;
164
- throughput = nbl_glsl_MC_runGenerateAndRemainderStream(precomp, gcs, rnps, rand, pdf, s);
166
+ throughput = nbl_glsl_MC_runGenerateAndRemainderStream(precomp,gcs,rnps,rand,pdf,s);
165
167
166
168
direction = s.L;
167
169
}
168
170
169
171
nbl_glsl_xoroshiro64star_state_t load_aux_vertex_attrs(
170
- in vec2 compactBary, in uvec3 indices, in uint batchInstanceGUID ,
172
+ in vec2 compactBary, in uvec3 indices, in nbl_glsl_ext_Mitsuba_Loader_instance_data_t batchInstanceData ,
171
173
in nbl_glsl_MC_oriented_material_t material,
172
174
in uvec2 outPixelLocation, in uint vertex_depth_mod_2
173
175
#ifdef TEX_PREFETCH_STREAM
@@ -178,19 +180,19 @@ nbl_glsl_xoroshiro64star_state_t load_aux_vertex_attrs(
178
180
// if we ever support spatially varying emissive, we'll need to hoist barycentric computation and UV fetching to the position fetching
179
181
#ifdef TEX_PREFETCH_STREAM
180
182
const mat3x2 uvs = mat3x2 (
181
- nbl_glsl_fetchVtxUV(indices[0 ],batchInstanceGUID ),
182
- nbl_glsl_fetchVtxUV(indices[1 ],batchInstanceGUID ),
183
- nbl_glsl_fetchVtxUV(indices[2 ],batchInstanceGUID )
183
+ nbl_glsl_fetchVtxUV(indices[0 ],batchInstanceData ),
184
+ nbl_glsl_fetchVtxUV(indices[1 ],batchInstanceData ),
185
+ nbl_glsl_fetchVtxUV(indices[2 ],batchInstanceData )
184
186
);
185
187
const nbl_glsl_MC_instr_stream_t tps = nbl_glsl_MC_oriented_material_t_getTexPrefetchStream(material);
186
188
#endif
187
189
// only needed for continuing
188
190
const mat3 normals = mat3 (
189
- nbl_glsl_fetchVtxNormal(indices[0 ],batchInstanceGUID ),
190
- nbl_glsl_fetchVtxNormal(indices[1 ],batchInstanceGUID ),
191
- nbl_glsl_fetchVtxNormal(indices[2 ],batchInstanceGUID )
191
+ nbl_glsl_fetchVtxNormal(indices[0 ],batchInstanceData ),
192
+ nbl_glsl_fetchVtxNormal(indices[1 ],batchInstanceData ),
193
+ nbl_glsl_fetchVtxNormal(indices[2 ],batchInstanceData )
192
194
);
193
-
195
+
194
196
#ifdef TEX_PREFETCH_STREAM
195
197
dUVdBary = mat2 (uvs[0 ]- uvs[2 ],uvs[1 ]- uvs[2 ]);
196
198
const vec2 UV = dUVdBary* compactBary+ uvs[2 ];
@@ -204,16 +206,18 @@ nbl_glsl_xoroshiro64star_state_t load_aux_vertex_attrs(
204
206
const nbl_glsl_xoroshiro64star_state_t scramble_start_state = imageLoad(scramblebuf,ivec3 (outPixelLocation,vertex_depth_mod_2)).rg;
205
207
206
208
// while waiting for the scramble state
209
+ normalizedN.x = dot (batchInstanceData.normalMatrixRow0,normal);
210
+ normalizedN.y = dot (batchInstanceData.normalMatrixRow1,normal);
211
+ normalizedN.z = dot (batchInstanceData.normalMatrixRow2,normal);
207
212
normalizedN = normalize (normal);
208
213
209
214
return scramble_start_state;
210
215
}
211
216
212
217
void generate_next_rays(
213
- in uint maxRaysToGen, in nbl_glsl_ext_Mitsuba_Loader_instance_data_t batchInstanceData,
214
- in nbl_glsl_MC_oriented_material_t material, in bool frontfacing, in uint vertex_depth,
218
+ in uint maxRaysToGen, in nbl_glsl_MC_oriented_material_t material, in bool frontfacing, in uint vertex_depth,
215
219
in nbl_glsl_xoroshiro64star_state_t scramble_start_state, in uint sampleID, in uvec2 outPixelLocation,
216
- in vec3 pos , vec3 geomNormal, in vec3 prevThroughput)
220
+ in vec3 origin , vec3 geomNormal, in vec3 prevThroughput)
217
221
{
218
222
// get material streams as well
219
223
const nbl_glsl_MC_instr_stream_t gcs = nbl_glsl_MC_oriented_material_t_getGenChoiceStream(material);
@@ -257,17 +261,16 @@ for (uint i=1u; i!=vertex_depth; i++)
257
261
// set up dispatch indirect
258
262
atomicMax(traceIndirect[vertex_depth_mod_2_inv].params.num_groups_x,(baseOutputID+ raysToAllocate- 1u)/ WORKGROUP_SIZE+ 1u);
259
263
260
- const mat4x3 batchWorldTform = batchInstanceData.tform;
261
264
uint offset = 0u;
262
265
for (uint i= 0u; i< maxRaysToGen; i++ )
263
266
if (maxT[i]!= 0 .f)
264
267
{
265
268
nbl_glsl_ext_RadeonRays_ray newRay;
266
269
// TODO: improve ray offsets
267
270
const float err = 1 .f/ 96 .f;
268
- newRay.origin = mat3 (batchWorldTform) * (pos +/* geomNormal/max(max(geomNormal.x,geomNormal.y),geomNormal.z)*sign(dot(geomNormal,direction[i]))*/ direction[i]* err) + batchWorldTform[ 3 ] ;
271
+ newRay.origin = origin +/* geomNormal/max(max(geomNormal.x,geomNormal.y),geomNormal.z)*sign(dot(geomNormal,direction[i]))*/ direction[i]* err;
269
272
newRay.maxT = maxT[i];
270
- newRay.direction = mat3 (batchWorldTform) * direction[i]; // normalize after ? (doesn't non-uniform scale screw up BxDF eval and generation?)
273
+ newRay.direction = direction[i]; // normalize after ? (doesn't non-uniform scale screw up BxDF eval and generation?)
271
274
newRay.time = packOutPixelLocation(outPixelLocation);
272
275
newRay.mask = - 1 ;
273
276
newRay._active = 1 ;
0 commit comments