Skip to content

Commit 3d0c59f

Browse files
committed
Add more decorellation
1 parent 50e1ea2 commit 3d0c59f

File tree

5 files changed

+34
-23
lines changed

5 files changed

+34
-23
lines changed

App/CL/camera.cl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ THE SOFTWARE.
2828
#include <../App/CL/utils.cl>
2929
#include <../App/CL/path.cl>
3030

31-
//#define SOBOL
32-
33-
31+
#define CMJ 1
32+
#define CMJ_DIM 4
3433

3534

3635
/// Ray generation kernel for perspective camera.
@@ -49,7 +48,8 @@ __kernel void PerspectiveCamera_GeneratePaths(
4948
__global ray* rays,
5049
__global SobolSampler* samplers,
5150
__global uint const* sobolmat,
52-
int reset
51+
int reset,
52+
int frame
5353
#ifndef NO_PATH_DATA
5454
,__global Path* paths
5555
#endif
@@ -73,7 +73,7 @@ __kernel void PerspectiveCamera_GeneratePaths(
7373
Rng rng;
7474
InitRng(randseed + globalid.x * 157 + 10433 * globalid.y, &rng);
7575

76-
#ifdef SOBOL
76+
#if SOBOL == 1
7777
__global SobolSampler* sampler = samplers + globalid.y * imgwidth + globalid.x;
7878

7979
if (reset)
@@ -89,8 +89,14 @@ __kernel void PerspectiveCamera_GeneratePaths(
8989
float2 sample0;
9090
sample0.x = SobolSampler_Sample1D(sampler->seq, kPixelX, sampler->s0, sobolmat);
9191
sample0.y = SobolSampler_Sample1D(sampler->seq, kPixelY, sampler->s0, sobolmat);
92-
#else
92+
#elif RANDOM == 1
9393
float2 sample0 = UniformSampler_Sample2D(&rng);
94+
#elif CMJ == 1
95+
// Pass defines current current light selection and current material selection
96+
int pass = frame / (CMJ_DIM * CMJ_DIM);
97+
int pattern0 = permute(globalid.y * imgwidth + globalid.x, (1024 * 1024), pass * 0xc13719e1);
98+
int subsample0 = permute(frame % (CMJ_DIM * CMJ_DIM), CMJ_DIM * CMJ_DIM, pattern0 * 0xc517e953);
99+
float2 sample0 = cmj(subsample0, CMJ_DIM, pattern0);
94100
#endif
95101

96102
// Calculate [0..1] image plane sample

App/CL/integrator_pt.cl

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ THE SOFTWARE.
4343
#define CRAZY_LOW_THROUGHPUT 0.0f
4444
#define CRAZY_HIGH_RADIANCE 3.f
4545
#define CRAZY_HIGH_DISTANCE 1000000.f
46-
#define CRAZY_LOW_DISTANCE 0.01f
46+
#define CRAZY_LOW_DISTANCE 0.001f
4747
#define REASONABLE_RADIANCE(x) (clamp((x), 0.f, CRAZY_HIGH_RADIANCE))
4848
#define NON_BLACK(x) (length(x) > 0.f)
4949

@@ -237,7 +237,7 @@ __kernel void ShadeVolume(
237237
}
238238
}
239239

240-
#define CMJ_DIM 16
240+
#define CMJ_DIM 4
241241

242242
// Handle ray-surface interaction possibly generating path continuation.
243243
// This is only applied to non-scattered paths.
@@ -317,6 +317,9 @@ __kernel void ShadeSurface(
317317
num_lights
318318
};
319319

320+
// Pass defines current current light selection and current material selection
321+
int pass = frame / (CMJ_DIM * CMJ_DIM);
322+
320323
// Only applied to active rays after compaction
321324
if (globalid < *numhits)
322325
{
@@ -369,18 +372,17 @@ __kernel void ShadeSurface(
369372
Rng rng;
370373
InitRng(rngseed + (globalid << 2) * 157 + 13, &rng);
371374

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);
378380

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);
384386

385387
float2 sample0 = cmj(subsample0, CMJ_DIM, pattern0);
386388
float2 sample1 = cmj(subsample1, CMJ_DIM, pattern1);
@@ -495,7 +497,8 @@ __kernel void ShadeSurface(
495497
float bxdfweight = 1.f;
496498
float lightweight = 1.f;
497499

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;
499502

500503
float3 throughput = Path_GetThroughput(path);
501504

App/CL/material.cl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ THE SOFTWARE.
2222
#ifndef MATERIAL_CL
2323
#define MATERIAL_CL
2424

25+
#define CMJ 1
26+
2527
#include <../App/CL/utils.cl>
2628
#include <../App/CL/random.cl>
2729
#include <../App/CL/texture.cl>
2830
#include <../App/CL/payload.cl>
2931
#include <../App/CL/bxdf.cl>
30-
//#define SOBOL
3132

3233
void Material_Select(
3334
// Scene data

App/PT/ptrenderer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ namespace Baikal
351351
genkernel.SetArg(5, m_render_data->samplers);
352352
genkernel.SetArg(6, m_render_data->sobolmat);
353353
genkernel.SetArg(7, m_resetsampler);
354-
genkernel.SetArg(8, m_render_data->paths);
354+
genkernel.SetArg(8, m_framecnt);
355+
genkernel.SetArg(9, m_render_data->paths);
355356
m_resetsampler = 0;
356357

357358
// Run generation kernel

App/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ float g_ao_radius = 1.f;
107107
float g_envmapmul = 1.f;
108108
float g_cspeed = 10.25f;
109109

110-
float3 g_camera_pos = float3(0.f, 4.f, 12.f);
110+
float3 g_camera_pos = float3(0.f, 4.f, 14.f);
111111
float3 g_camera_at = float3(0.f, 1.f, 0.f);
112112
float3 g_camera_up = float3(0.f, 1.f, 0.f);
113113

0 commit comments

Comments
 (0)