@@ -43,7 +43,7 @@ THE SOFTWARE.
43
43
#define CRAZY_LOW_THROUGHPUT 0.0f
44
44
#define CRAZY_HIGH_RADIANCE 3.f
45
45
#define CRAZY_HIGH_DISTANCE 1000000.f
46
- #define CRAZY_LOW_DISTANCE 0.01f
46
+ #define CRAZY_LOW_DISTANCE 0.001f
47
47
#define REASONABLE_RADIANCE (x ) (clamp((x), 0.f, CRAZY_HIGH_RADIANCE))
48
48
#define NON_BLACK (x ) (length(x) > 0.f)
49
49
@@ -237,7 +237,7 @@ __kernel void ShadeVolume(
237
237
}
238
238
}
239
239
240
- #define CMJ_DIM 16
240
+ #define CMJ_DIM 4
241
241
242
242
// Handle ray-surface interaction possibly generating path continuation.
243
243
// This is only applied to non-scattered paths.
@@ -317,6 +317,9 @@ __kernel void ShadeSurface(
317
317
num_lights
318
318
};
319
319
320
+ // Pass defines current current light selection and current material selection
321
+ int pass = frame / (CMJ_DIM * CMJ_DIM );
322
+
320
323
// Only applied to active rays after compaction
321
324
if (globalid < * numhits )
322
325
{
@@ -369,18 +372,17 @@ __kernel void ShadeSurface(
369
372
Rng rng ;
370
373
InitRng (rngseed + (globalid << 2 ) * 157 + 13 , & rng );
371
374
372
- int pass = frame / (CMJ_DIM * CMJ_DIM );
373
- int subsample0 = permute (frame % (CMJ_DIM * CMJ_DIM ), CMJ_DIM * CMJ_DIM , (pass + pixelidx + bounce ) * 0xc517e953 );
374
- int subsample1 = permute (frame % (CMJ_DIM * CMJ_DIM ), CMJ_DIM * CMJ_DIM , (pass + pixelidx + bounce + 1 ) * 0xc517e953 );
375
- int subsample2 = permute (frame % (CMJ_DIM * CMJ_DIM ), CMJ_DIM * CMJ_DIM , (pass + pixelidx + bounce + 2 ) * 0xc517e953 );
376
- int subsample3 = permute (frame % (CMJ_DIM * CMJ_DIM ), CMJ_DIM * CMJ_DIM , (pass + pixelidx + bounce + 3 ) * 0xc517e953 );
377
- int subsample4 = permute (frame % (CMJ_DIM * CMJ_DIM ), CMJ_DIM * CMJ_DIM , (pass + pixelidx + bounce + 4 ) * 0xc517e953 );
375
+ int pattern0 = permute (pixelidx , (1024 * 1024 ), pass * 1024 * 1024 * 20 * 5 + bounce * 1024 * 1024 * 5 + pixelidx );
376
+ int pattern1 = permute (pixelidx , (1024 * 1024 ), pass * 1024 * 1024 * 20 * 5 + bounce * 1024 * 1024 * 5 + pixelidx + 1 );
377
+ int pattern2 = permute (pixelidx , (1024 * 1024 ), pass * 1024 * 1024 * 20 * 5 + bounce * 1024 * 1024 * 5 + pixelidx + 2 );
378
+ int pattern3 = permute (pixelidx , (1024 * 1024 ), pass * 1024 * 1024 * 20 * 5 + bounce * 1024 * 1024 * 5 + pixelidx + 3 );
379
+ int pattern4 = permute (pixelidx , (1024 * 1024 ), pass * 1024 * 1024 * 20 * 5 + bounce * 1024 * 1024 * 5 + pixelidx + 4 );
378
380
379
- int pattern0 = ( pass + bounce + pixelidx ) % 13331 ;
380
- int pattern1 = ( pass + bounce + pixelidx + 1 ) % 13331 ;
381
- int pattern2 = ( pass + bounce + pixelidx + 2 ) % 13331 ;
382
- int pattern3 = ( pass + bounce + pixelidx + 3 ) % 13331 ;
383
- int pattern4 = ( pass + bounce + pixelidx + 4 ) % 13331 ;
381
+ int subsample0 = permute ( frame % ( CMJ_DIM * CMJ_DIM ), CMJ_DIM * CMJ_DIM , pattern4 * pixelidx * 0xc117d953 ) ;
382
+ int subsample1 = permute ( frame % ( CMJ_DIM * CMJ_DIM ), CMJ_DIM * CMJ_DIM , pattern3 * pixelidx * 0xc117d953 ) ;
383
+ int subsample2 = permute ( frame % ( CMJ_DIM * CMJ_DIM ), CMJ_DIM * CMJ_DIM , pattern2 * pixelidx * 0xc117d953 ) ;
384
+ int subsample3 = permute ( frame % ( CMJ_DIM * CMJ_DIM ), CMJ_DIM * CMJ_DIM , pattern1 * pixelidx * 0xc117d953 ) ;
385
+ int subsample4 = permute ( frame % ( CMJ_DIM * CMJ_DIM ), CMJ_DIM * CMJ_DIM , pattern0 * pixelidx * 0xc117d953 ) ;
384
386
385
387
float2 sample0 = cmj (subsample0 , CMJ_DIM , pattern0 );
386
388
float2 sample1 = cmj (subsample1 , CMJ_DIM , pattern1 );
@@ -495,7 +497,8 @@ __kernel void ShadeSurface(
495
497
float bxdfweight = 1.f ;
496
498
float lightweight = 1.f ;
497
499
498
- int light_idx = num_lights > 0 ? Scene_SampleLight (& scene , sample0 .y , & selection_pdf ) : -1 ;
500
+ int light_idx = pass % num_lights ;
501
+ selection_pdf = 1.f / num_lights ;
499
502
500
503
float3 throughput = Path_GetThroughput (path );
501
504
0 commit comments