[Bf-cycles] Why is PDF's normalized by fraction of PI instead of one?

Aurel W. aurel.w at gmail.com
Mon Nov 7 12:54:47 CET 2011

In old Blender Internal the lambert shader was even not normalized by
pi and to keep volume rendering consistent the phase functions were
also scaled by a factor of pi.

I also extended BI with a monte carlo volume renderer some time ago
where I had the same issue but again, due to compatibility with
surface shading I had to scale by a factor of pi.

> Most ( if not all) angle samplers use sample_cos_hemisphere(),
> sample_uniform_sphere(), etc. functions from
> intern/cycles/kernel/kernel_montecarlo.h. I use them too in volumetric
> patch blindly copying by analogy from svn_diffuse.c.

I can just give you the advise to stick exactly to the RTE and try to
get the basic math right here. Since being off by such a factor can
cause a lot of troubles, if they manifest in a render engine.


On 7 November 2011 03:16, Brecht Van Lommel <brechtvanlommel at pandora.be> wrote:
> Hi,
> I asked myself a similar question some time ago, here is what I understand.
> On Sun, Nov 6, 2011 at 11:59 PM, storm <kartochka22 at yandex.ru> wrote:
>> Why pdf = costheta *M_1_PI_F instead of costheta * 1.0f ?
>> It make sense if our input random values (u,v) are actual angles and
>> have range [-PI,PI] or [0, 2*PI] but we use uniform random values in
>> rande [0..1] as input, so as result we have scaled pdf. If we sample
>> uniform sphere, it is 4*PI steradians and PDF is 1/(4*M_PI). Same for
>> half sphere, 2*PI steradians, but our random samples [0..1] isn't we
>> must treat area as 0.5 in our measurement domain ?
>> As I understend, MC integrator goal (if we use uniform sampling
>> probability) is just sum all sample values and divide by number of
>> samples. Imagine (u,v) as 2d square, PDF actually 1*1 = 1. Why it is
>> different for angles?
> What is considered to be the integration domain is a matter of choice.
> If we'd say it is the unit square, then the pdf would indeed look
> different. Here the convention is that it's the hemisphere, which has
> area 2*pi.
> By definition, integrating the probability density function over the
> domain should give 1. The formula for integrating a function f over
> the hemisphere is this (can be pasted into wolfram alpha). If we
> replace f(theta, phi) by cos(theta)/pi, it happily works out to 1.
> integrate f(theta, phi)*sin(theta), theta from 0 to pi/2, phi from 0 to 2pi
> I'm not sure if this integral helps you understand it well, but it's
> similar to the one used for integrating over a sphere with spherical
> coordinates.
> Brecht.
> _______________________________________________
> Bf-cycles mailing list
> Bf-cycles at blender.org
> http://lists.blender.org/mailman/listinfo/bf-cycles

More information about the Bf-cycles mailing list