snogglethorpe/snogray — Issue #15: Add some hack to reduce "speckling"
Author: snogglethorpe
Created: 2011-12-02 09:11:39+00:00
State: open

One of the most annoying rendering artifacts is "speckles" -- rare but very noticeable bright pixels in the middle of otherwise average areas. Note that this is distinct from general rendering noise, which is generally well behaved, relatively unobjectionable (it looks a bit like film grain), and can be reasonably controlled by increased sampling. These bright speckles on the other hand, are reduced by increasing sampling, but because they're so obvious, are still annoying even at quite high sample rate.

I think such speckles are not a bug, but just an artifact of unbiased monte-carlo methods -- they show up mainly when using global illumination, and seem to represent very rare but valid lighting paths (remember, unlikely paths have their value greatly boosted by their very unlikeliness, due to dividing by PDF values). However they're still very ugly.

To remove these, it seems reasonable to simply try and squash any single samples that are dramatically greater than their immediate neighborhood; this obviously makes the result biased, but I think will result in a much more attractive result without any _obvious_ change.

My idea: calculate the average sample value for a pixel, and clamp all samples for the pixel to some multiple (10x, 20x?, something based on the number of samples?) of that average. Then any pixel with a reasonable number of very bright samples will still be obvious bright, because those bright samples will make the average pretty high, and even single bright samples will remain bright, but not enough to completely overwhelm the pixel brightness by themselves.