For those familiar with smallpt, the ray tracer in 99 lines: I am checking the code, and there is something that is not clear to me in the DIFFUSE ray scattering.
After the rays are shot, they keep bouncing until the if-statement with the Russian Roulette stops them.
if (++depth>5) if (erand48(Xi)<p) f=f*(1/p); else return obj.e;
This means that, when rays are scattered and hit the light source, they don't actually stop there (which is what I thought at first: rays bounce until they hit the light source, or until they reach a specific amount of bounces). Am I missing something?
pis gonna be zero for light sources. Light sources are defined by emission variable and color is zero for them. Hence the reflectance parameter calculated previous to this line (
p) would be zero giving us