Skip to content

Commit dfc1762

Browse files
fix bias to high spp renders caused by aggressive ray throughput threshold
1 parent eb0d643 commit dfc1762

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples_tests/22.RaytracedAO/raytraceCommon.glsl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ void storeAccumulation(in vec3 color, in uvec3 coord)
7979
}
8080
void storeAccumulation(in vec3 prev, in vec3 delta, in uvec3 coord)
8181
{
82-
if (any(greaterThan(abs(delta),vec3(nbl_glsl_FLT_MIN*16.f))))
83-
storeAccumulation(prev+delta,coord);
82+
const vec3 newVal = prev+delta;
83+
const uvec3 diff = floatBitsToUint(newVal)^floatBitsToUint(prev);
84+
if (bool((diff.x|diff.y|diff.z)&0x7ffffff0u))
85+
storeAccumulation(newVal,coord);
8486
}
8587

8688
vec3 fetchAlbedo(in uvec3 coord)
@@ -324,8 +326,8 @@ void generate_next_rays(
324326
worldspaceNormal += result.aov.normal/float(maxRaysToGen);
325327

326328
nextThroughput[i] = prevThroughput*result.quotient;
327-
// do denormalized half floats flush to 0 ?
328-
if (max(max(nextThroughput[i].x,nextThroughput[i].y),nextThroughput[i].z)>=exp2(-14.f))
329+
// TODO: add some sort of factor to this inequality that could account for highest possible emission (direct or indirect) we could encounter
330+
if (max(max(nextThroughput[i].x,nextThroughput[i].y),nextThroughput[i].z)>exp2(-19.f)) // match output mantissa (won't contribute anything afterwards)
329331
{
330332
maxT[i] = nbl_glsl_FLT_MAX;
331333
nextAoVThroughputScale[i] = prevAoVThroughputScale*result.aov.throughputFactor;

0 commit comments

Comments
 (0)