Skip to content

Commit a4426a6

Browse files
moved the box muller transform out to out GLSL library
1 parent 78808d4 commit a4426a6

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

examples_tests/22.RaytracedAO/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ int main()
237237

238238
if (generateNewSamples)
239239
{
240+
/** TODO: redo the sampling
241+
Locality Level 0: the 6 or 4 dimensions consumed for BSDF + NEE sampling
242+
Locality Level 1: the N samples per dispatch which will be consumed in parallel
243+
Locality Level 2: the k dimensions batches (where D=4k or 6k) consumed as we recurse deeper
244+
Locality Level 3: the z sample batches (where T=zN) consumed as we progressively add samples
245+
**/
240246
constexpr uint32_t Channels = 3u;
241247
static_assert(Renderer::MaxDimensions%Channels==0u,"We cannot have this!");
242248
core::OwenSampler sampler(Renderer::MaxDimensions,0xdeadbeefu);

examples_tests/42.FragmentShaderPathTracer/common.glsl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ layout(location = 0) out vec4 pixelColor;
2323
#include <nbl/builtin/glsl/math/constants.glsl>
2424
#include <nbl/builtin/glsl/utils/common.glsl>
2525

26-
//! @Crisspl move this to `nbl/builtin/glsl/sampling.glsl` (along with the circle transform)
27-
vec2 nbl_glsl_BoxMullerTransform(in vec2 xi, in float stddev)
28-
{
29-
float sinPhi, cosPhi;
30-
nbl_glsl_sincos(2.0 * nbl_glsl_PI * xi.y - nbl_glsl_PI, sinPhi, cosPhi);
31-
return vec2(cosPhi, sinPhi) * sqrt(-2.0 * log(xi.x)) * stddev;
32-
}
26+
#include <nbl/builtin/glsl/sampling/box_muller_transform.glsl>
3327

3428
layout(set = 1, binding = 0, row_major, std140) uniform UBO
3529
{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef _NBL_BUILTIN_GLSL_BOX_MULLER_TRANSFORM_INCLUDED_
2+
#define _NBL_BUILTIN_GLSL_BOX_MULLER_TRANSFORM_INCLUDED_
3+
4+
#include <nbl/builtin/glsl/math/functions.glsl>
5+
6+
vec2 nbl_glsl_BoxMullerTransform(in vec2 xi, in float stddev)
7+
{
8+
float sinPhi, cosPhi;
9+
nbl_glsl_sincos(2.0 * nbl_glsl_PI * xi.y - nbl_glsl_PI, sinPhi, cosPhi);
10+
return vec2(cosPhi, sinPhi) * sqrt(-2.0 * log(xi.x)) * stddev;
11+
}
12+
13+
#endif

src/nbl/builtin/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ set(nbl_resources_to_embed
8585
"nbl/builtin/glsl/random/xoroshiro.glsl"
8686
# sampling
8787
"nbl/builtin/glsl/sampling/bilinear.glsl"
88+
"nbl/builtin/glsl/sampling/box_muller_transform.glsl"
8889
"nbl/builtin/glsl/sampling/concentric_mapping.glsl"
8990
"nbl/builtin/glsl/sampling/cos_weighted.glsl"
9091
"nbl/builtin/glsl/sampling/linear.glsl"

0 commit comments

Comments
 (0)