@@ -210,9 +210,10 @@ nbl_glsl_xoroshiro64star_state_t load_aux_vertex_attrs(
210
210
}
211
211
212
212
void generate_next_rays(
213
- in uint maxRaysToGen, in mat4x3 batchWorldTform, in nbl_glsl_MC_oriented_material_t material, in bool frontfacing,
214
- in uint vertex_depth, in nbl_glsl_xoroshiro64star_state_t scramble_start_state, in uint sampleID, in uvec2 outPixelLocation,
215
- in vec3 origin, vec3 geomNormal, in vec3 prevThroughput)
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,
215
+ in nbl_glsl_xoroshiro64star_state_t scramble_start_state, in uint sampleID, in uvec2 outPixelLocation,
216
+ in vec3 pos, vec3 geomNormal, in vec3 prevThroughput)
216
217
{
217
218
// get material streams as well
218
219
const nbl_glsl_MC_instr_stream_t gcs = nbl_glsl_MC_oriented_material_t_getGenChoiceStream(material);
@@ -231,6 +232,12 @@ void generate_next_rays(
231
232
// prepare rays
232
233
uint raysToAllocate = 0u;
233
234
float maxT[MAX_RAYS_GENERATED]; vec3 direction[MAX_RAYS_GENERATED]; vec3 nextThroughput[MAX_RAYS_GENERATED];
235
+ for (uint i= 1u; i!= vertex_depth; i++ )
236
+ {
237
+ nbl_glsl_xoroshiro64star(scramble_start_state);
238
+ nbl_glsl_xoroshiro64star(scramble_start_state);
239
+ nbl_glsl_xoroshiro64star(scramble_start_state);
240
+ }
234
241
for (uint i= 0u; i< maxRaysToGen; i++ )
235
242
{
236
243
nbl_glsl_xoroshiro64star_state_t scramble_state = scramble_start_state;
@@ -250,17 +257,17 @@ void generate_next_rays(
250
257
// set up dispatch indirect
251
258
atomicMax(traceIndirect[vertex_depth_mod_2_inv].params.num_groups_x,(baseOutputID+ raysToAllocate- 1u)/ WORKGROUP_SIZE+ 1u);
252
259
253
- const mat3 batchWorldScaleRot = mat3 (batchWorldTform) ;
260
+ const mat4x3 batchWorldTform = batchInstanceData.tform ;
254
261
uint offset = 0u;
255
262
for (uint i= 0u; i< maxRaysToGen; i++ )
256
263
if (maxT[i]!= 0 .f)
257
264
{
258
265
nbl_glsl_ext_RadeonRays_ray newRay;
259
266
// TODO: improve ray offsets
260
267
const float err = 1 .f/ 96 .f;
261
- newRay.origin = origin +/* geomNormal/max(max(geomNormal.x,geomNormal.y),geomNormal.z)*sign(dot(geomNormal,direction[i]))*/ direction[i]* err;
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 ] ;
262
269
newRay.maxT = maxT[i];
263
- newRay.direction = batchWorldScaleRot * direction[i];
270
+ newRay.direction = mat3 (batchWorldTform) * direction[i]; // normalize after ? (doesn't non-uniform scale screw up BxDF eval and generation?)
264
271
newRay.time = packOutPixelLocation(outPixelLocation);
265
272
newRay.mask = - 1 ;
266
273
newRay._active = 1 ;
0 commit comments