How do I determine how many (jittered) rays to trace for a given pixel, as a function of the statistics of a small initial set of test rays? Also, what size should the initial set be? (it's currently 20, based on eyeball tests)

Currently I'm calculating the variance of the initial set and multiplying that by a arbitrary number (4000..40,000) to give the number of additional rays to trace. This gives acceptable results but I would prefer something grounded in real statistics, mostly so I can get some kind of confidence interval for how close to the true mean my sample mean is likely to be.

Additional possibly relevant info: RGB values are 0..1, pixel color is mean of all samples, jitter is currently random but I'm looking into using a Halton sequence to ensure better distribution, I am modeling diffuse inter-reflections, I'm rendering on a CPU using two threads per core, each rendering thread gets a row of pixels all to itself

  • $\begingroup$ It depends on your scene, materials and the phenomena you are trying to model. Say you only want to model specular reflections, then 1 ray is enough. Say you want to model diffuse inter-reflections, then you should cast thousands of rays to converge in most cases. An interesting approach would be to cast as many rays as you need until reaching convergance. You can test the convergance per pixel, using the difference between previous and new color. If you are using CPU, this can be the best way. If on GPU, then thread divergance can be a problem... $\endgroup$ – jpaguerre May 31 at 1:28
  • $\begingroup$ I am modeling diffuse inter-reflections. I will add that to the question. I tried detecting convergence by checking the amount of change due to the most recent ray, but it never went above a few hundred rays, even though some areas continued to visibly improve up past 100,000 rays. I'm not using a GPU currently. $\endgroup$ – Octa9on May 31 at 5:05
  • $\begingroup$ Are you modelling múltiple bounces? In that case you want to use some caching strategy to reduce the calculations, like irradiance caching. $\endgroup$ – jpaguerre May 31 at 14:01
  • 1
    $\begingroup$ Another thing to analyze is using pixel coherence to improve the calculations. Nearby pixel data (like number of rays until convergance) can help in the calculation of the present pixel $\endgroup$ – jpaguerre May 31 at 14:07
  • 1
    $\begingroup$ Be careful with your convergance algoithm. What threshold are you using? Try smaller values. A good thing to so is to use ray buckets to study convergance. For example, you cast 16 rays and test for convergance between current pixel color and the average of the 16 new colors. $\endgroup$ – jpaguerre May 31 at 14:12

I found a paper from 1997 that addresses this subject: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.