How does Cycles calculate noise levels?

I’d like to investigate the noise distribution in final renders, in order to more effectively use Cycles’ adaptive sampling feature. The ultimate goal, if something useful does comes up, would be to develop tools to help optimize the sampling parameters.

I tried searching Cycles’ source code to see how it is calculated, but couldn’t find it. Does anyone know which algorithm is used to assess the render’s noise levels (to enforce the Noise Threshold, for example)? Alternatively, could someone point me to the bit of code in which it is calculated?

Cheers!

1 Like

It’s loosely based off of: A hierarchical automatic stopping condition for Monte Carlo global illumination

You can search the cycles code for film_write_adaptive_buffer and film_adaptive_sampling_convergence_check. Search forward and backwards from there.

Generally the algorithm is as follows:

  • Trace a few samples (say 16) and accumulate those all into the primary buffer as normal
  • Store half of the samples (maybe all the even numbered ones) in a secondary/aux buffer
  • Compare the aux buffer to the full buffer
  • Is it close enough? We’re done. If it’s not close enough, do another 16 etc. etc.

In that model the primary gotcha is the following: Is that aux buffer close enough to the primary because the pixel values are truly converged and 8 additional samples didn’t mean much (a true positive)? Or does it happen to be close enough to the primary buffer because not many rays connected with the surface to begin with (a false positive).

Something to look at is the “minimum samples” you selected for the scene. Adaptive sampling only takes over after that many samples have been traced over all pixels. It helps force a sufficient number of samples over all pixels to help alleviate the false positives.

6 Likes

Thank you very much for the careful explanation! I’ll have a look in the paper and the code.