While following scratchapixel's tutorial on indirect diffuse implementation in path tracing, the samples gets divided by the pdf, which in case of a uniform pdf results in $1/2\pi$ so we have that the sum of N samples gets multiplied by this factor: $$k=\frac{1}{N * \frac{1}{2 \pi}} = \frac{2\pi}{N}$$
The problem with this is that unless the albedo color is very dark, the final color quickly increases:
(From "Step 7: Add the Contribution of the Indirect Diffuse..." in the link above)
$$hitColor = (directDiffuse + \frac{2\pi * indirectDiffuse}{N}) * \frac{albedo}{\pi}; $$
Other implementations instead just average the samples and the $2\pi$ term above is completely absent, like in Shirley's "ray tracing in a weekend" p.20
Which one is correct?
There's a difference in Shirley's and scratchapixel implementation, in the fact that Shirley's is a progressive path tracer (evaluates one path at a time)
While scratchapixel's is a non-progressive or branched path tracer, evaluating multiple paths at once:
But I believe this does not allow us to remove the $2\pi$ term in the former, because we are doing the same thing (sampling the BRDF hemisphere) albeit differently.
When evaluating direct lighting with point lights, the solid angle term is also completely absent, which makes things even more strange:
Here the integral over the hemisphere is 0 except in the direction $\omega i$, but (for example considering only diffuse) we only use:
$$ L(P) = albedo*L(\omega i, P)*cos\theta$$
where $L(P)$ is the radiance from the point $P$, and $L(\omega i, P)$ gets replaced with our light radiance, $\theta$ is the angle with from $\omega i$ to the surface normal. Where has the solid angle term ($ \omega i$) gone?
The problem with this is that unless the albedo color is very dark, the final color quickly increases
- how is it a problem, and how does it "quickly increase"?Other implementations instead...
- link those. $\endgroup$The 2pi is missing in RT in a weekend, because it's using cosine weighted sampling and the constant π factor is assumed to cancel with an implicit factor in the albedo.
- If the π term cancels out it should leave a $2$ factor, which isn't present? -Point lights are represented though Dirac deltas which gets rid of the integrand and dωi
- Thanks for the explaination, this confirms what I was suspecting $\endgroup$