Importance sampling, color scaling back
Board:
Home
Board index
Raytracing
General Development
(L) [2012/11/02] [tby tuomlarsen] [Importance sampling, color scaling] Wayback!Hi,
please, I have two questions regarding path tracing:
- when doing "importance sampling" (is this the same as "emitter sampling"?), do I have to "[l]oop over any lights" and add their contributions to final result or is it also ok just to pick one light randomly, multiply its contribution by the number of lights and add this to the result?
- when reading the source of [LINK http://kevinbeason.com/smallpt/], on line #55 there is this Code: [LINK # Select all]f=f*(1/p);. Why is it there? What that is do?
(L) [2012/11/04] [tby graphicsMan] [Importance sampling, color scaling] Wayback!You can either loop all the lights, or pick one or any number at random.  If you're importance sampling, you probably want to pick fewer lights.  The idea is that you could pick one light, say based on total emission power, and then you divide by the probability of picking that light.  
This is the same as your example of picking one light and dividing by the number of lights, but only if all lights have the same power.
In Kevin's code, he is performing russian roulette.  The idea is that you can decide whether or not to continue tracing.  You do this based on a probability.  If you decide to terminate, you have zero further contribution.  But if you do not terminate, you have to divide by the probability.  This will scale the values by an amount greater than 1 in order to compensate for the times you decide to terminate.
(L) [2012/11/04] [tby tuomlarsen] [Importance sampling, color scaling] Wayback!Thank you for the explanations!
One more question though regarding the importance samling, if I were to pick a light and scale by the number of lights, why does it matter that they have to be of the same strength? If I pick the lights at random, on average it should be the same as picking based on total emission power. I mean, some time I pick strong light, another time a weak one, ..?
Also, in Kevin's code, why does he uses "the maximum of R, G, B" for the Russian Roulette? Why not, say their average or mean or something else? I assume the image converges whether is maximum or average, perhaps it's just some heuristic to make it converge faster?
back