Skip to content

Commit 95ea915

Browse files
authored
Fix paths that don't have light contributions (#16)
fix paths that don't have light contributions
2 parents 06f025f + 6cb6208 commit 95ea915

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

assets/shaders/RayTracing.rgen

+9-1
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,19 @@ void main()
3636
vec3 rayColor = vec3(1);
3737

3838
// Ray scatters are handled in this loop. There are no recursive traceNV() calls in other shaders.
39-
for (uint b = 0; b < Camera.NumberOfBounces; ++b)
39+
for (uint b = 0; b <= Camera.NumberOfBounces; ++b)
4040
{
4141
const float tMin = 0.001;
4242
const float tMax = 10000.0;
4343

44+
// If we've exceeded the ray bounce limit without hitting a light source, no light is gathered.
45+
// Light emitting materials never scatter in this implementation, allowing us to make this logical shortcut.
46+
if (b == Camera.NumberOfBounces)
47+
{
48+
rayColor = vec3(0, 0, 0);
49+
break;
50+
}
51+
4452
traceNV(
4553
Scene, gl_RayFlagsOpaqueNV, 0xff,
4654
0 /*sbtRecordOffset*/, 0 /*sbtRecordStride*/, 0 /*missIndex*/,

0 commit comments

Comments
 (0)