Skip to content

Commit 0bcf130

Browse files
committed
Fix Sobol
1 parent eed2625 commit 0bcf130

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

App/CL/camera.cl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ __kernel void PerspectiveCamera_GeneratePaths(
4343
uint rngseed,
4444
// Output rays
4545
__global ray* rays,
46-
__global uint const* random,
46+
__global uint* random,
4747
__global uint const* sobolmat,
4848
int frame
4949
#ifndef NO_PATH_DATA
@@ -68,6 +68,12 @@ __kernel void PerspectiveCamera_GeneratePaths(
6868
Sampler sampler;
6969
#if SAMPLER == SOBOL
7070
uint scramble = random[globalid.x + imgwidth * globalid.y] * 0x1fe3434f;
71+
72+
if (frame & 0xF)
73+
{
74+
random[globalid.x + imgwidth * globalid.y] = WangHash(scramble);
75+
}
76+
7177
Sampler_Init(&sampler, frame, SAMPLE_DIM_CAMERA_OFFSET, scramble);
7278
#elif SAMPLER == RANDOM
7379
uint scramble = globalid.x + imgwidth * globalid.y * rngseed;
@@ -152,6 +158,12 @@ __kernel void PerspectiveCameraDof_GeneratePaths(
152158
Sampler sampler;
153159
#if SAMPLER == SOBOL
154160
uint scramble = random[globalid.x + imgwidth * globalid.y] * 0x1fe3434f;
161+
162+
if (frame & 0xF)
163+
{
164+
random[globalid.x + imgwidth * globalid.y] = WangHash(scramble);
165+
}
166+
155167
Sampler_Init(&sampler, frame, SAMPLE_DIM_CAMERA_OFFSET, scramble);
156168
#elif SAMPLER == RANDOM
157169
uint scramble = globalid.x + imgwidth * globalid.y * rngseed;

App/CL/common.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ THE SOFTWARE.
3636
#define SOBOL 2
3737
#define CMJ 3
3838

39-
#define SAMPLER CMJ
39+
#define SAMPLER SOBOL
4040

4141
#define CMJ_DIM 4
4242

App/PT/ptrenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ namespace Baikal
287287
std::vector<std::uint32_t> random_buffer(output.width() * output.height());
288288
std::generate(random_buffer.begin(), random_buffer.end(), std::rand);
289289

290-
m_render_data->random = m_context.CreateBuffer<std::uint32_t>(output.width() * output.height(), CL_MEM_READ_ONLY, &random_buffer[0]);
290+
m_render_data->random = m_context.CreateBuffer<std::uint32_t>(output.width() * output.height(), CL_MEM_READ_WRITE, &random_buffer[0]);
291291
m_vidmemws += output.width() * output.height() * sizeof(std::uint32_t);
292292

293293
std::vector<int> initdata(output.width() * output.height());

0 commit comments

Comments
 (0)