summaryrefslogtreecommitdiff
path: root/hitlist.h
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-04-14 19:04:12 +0800
committerKeuin <[email protected]>2022-04-14 19:04:12 +0800
commit25305140df28c19f622209bb514d290ad6e6486b (patch)
tree5e3bddf7def77ad2219c3e9506b40c30ac8e2476 /hitlist.h
parentc9220aecd2c463c4ccfcec84a22fc2c0145db782 (diff)
Fix shadow acne problem.
Diffstat (limited to 'hitlist.h')
-rw-r--r--hitlist.h9
1 files changed, 8 insertions, 1 deletions
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;