From 25305140df28c19f622209bb514d290ad6e6486b Mon Sep 17 00:00:00 2001 From: Keuin Date: Thu, 14 Apr 2022 19:04:12 +0800 Subject: Fix shadow acne problem. --- hitlist.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hitlist.h b/hitlist.h index 9b02819..10be932 100644 --- a/hitlist.h +++ b/hitlist.h @@ -48,7 +48,14 @@ public: // Check the nearest object we hit for (const auto &obj: objects) { double t_; - if (obj->hit(r, t_, 0.0) && t_ < hit_t) { + // Fix the Shadow Acne problem + // Some diffused rays starts off from a point on the surface, + // while hit the surface very quickly at some small t like +-1e-10 or so. + // This decays the ray by accident, causing black pixels on the output image. + // We simply drop hits very near the surface + // (i.e. t is a very small positive number) to solve this problem. + static constexpr double t_min = 1e-8; + if (obj->hit(r, t_, t_min) && t_ < hit_t) { hit = true; hit_t = t_; hit_obj = obj; -- cgit v1.2.3