# Handling shadow acne for dynamic surfaces

My path-tracer is generally fine and gives good output for regular test scenes, but I've noticed dense fireflies and dark speckles over fractal surfaces. The noise disappears if I render without light gathers (or zero every gather) and definitely isn't driven by hidden NaNs, so I suspect it's happening because fractals are naturally "rough" while my occlusion tests assume smooth surfaces (with constant shadow-ray offsets).

Would it be possible to evaluate local distance variance at each intersection and scale my shadow-ray offsets appropriately? Would it have a significant effect if so, or would I be better off writing a denoiser?

A few different test images with constant shadow offset; explicit light sampling is always performed with MIS (one BXDF sample, one spatial sample).

Explicit light sampling for a fractal surface, 4096spp, $2\epsilon$ ray offset

Classical path tracing for a fractal surface, 4096spp, no explicit shadow rays

Explicit light sampling for a sphere, 4096spp, $2\epsilon$ ray offset

Classical path tracing for a sphere, 4096spp, no explicit shadow rays

• Is it possible some intersections / shadow-ray-origins are landing inside your shape ? If your surfaces are 1 sided then from the inside you would almost certainly get a path to your large light, which would explain the bright pixels. I can see you have ring-artifacts on the sphere with explicit light sampling, which is usually a symptom of numerical imprecision. How is your shape defined? Is ray marching involved? – PaulHK Jul 25 '18 at 8:50
• Yes, everything's ray-marched directly inside the shader; the fractal is a quaternionic julia DE and the sphere is just the standard spherical SDF. I thought the same thing after I posted this, so I changed to an $8\epsilon$ offset instead. It fixed the ringing on the sphere, but didn't do anything for the noise on the julia's surface. – Paul Ferris Jul 25 '18 at 10:40
• Very thin sections of geometry can be a problem for ray marchers as you can step through them and if using a SDF you can get increased distance when the ray steps through a thin wall making this error hard to detect. Another issue is acute angle V shaped geometry were a ray could land in the part of the V where both faces are so close together that adding an epsilon from the surface of one side of the V means you end up behind the neighbouring surface. – PaulHK Jul 27 '18 at 2:02
• Mmm, that's why I wanted to adapt the offset to the local roughness. Tighter v-shapes should have smaller epsilons. – Paul Ferris Jul 27 '18 at 2:32
• I guess that doesn't stop shadow rays in rough areas being occluded after they leave, though. What would you suggest? – Paul Ferris Jul 27 '18 at 2:35