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

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Nov 7 03:16:43 CET 2011

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.