Skip to content

Commit 33d8a01

Browse files
committed
handle NAN and INF radiance values
1 parent aaa4123 commit 33d8a01

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/pathtrace.cu

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ __global__ void computeIntersections(
176176
// If not first ray, preserve previous sampling information for
177177
// MIS calculation
178178
intersec.prevPos = segment.ray.origin;
179-
// intersec.prevBSDFPdf = segment.BSDFPdf;
180179
}
181180
}
182181
else {
@@ -299,7 +298,6 @@ __global__ void pathIntegSampleSurface(
299298
segment.remainingBounces--;
300299
}
301300
}
302-
//if (depth == 1)
303301
segment.radiance += accRadiance;
304302
}
305303

@@ -310,7 +308,11 @@ __global__ void finalGather(int nPaths, glm::vec3* image, PathSegment* iteration
310308
if (index < nPaths) {
311309
PathSegment iterationPath = iterationPaths[index];
312310
if (iterationPath.pixelIndex >= 0 && iterationPath.remainingBounces <= 0) {
313-
image[iterationPath.pixelIndex] += iterationPath.radiance;
311+
glm::vec3 r = iterationPath.radiance;
312+
if (isnan(r.x) || isnan(r.y) || isnan(r.z) || isinf(r.x) || isinf(r.y) || isinf(r.z)) {
313+
return;
314+
}
315+
image[iterationPath.pixelIndex] += glm::clamp(r, glm::vec3(0.f), glm::vec3(FLT_MAX / 10.f));
314316
}
315317
}
316318
}

0 commit comments

Comments
 (0)