Sign in to follow this  
jameszhao00

Point Light vs a single MC sample

Recommended Posts

I'm trying to implement a path tracer at the moment, and writing out the formula for a point light gives me

(area of cos(theta)*sin(theta) in the hemisphere) * normalized lambert * cos(theta)

or

pi * L/pi * cos(theta)

However, writing out a single Monte Carlo sample gives me

(area of integration) * 1 / (Number of samples) * normalized lambert * cos(theta)

(2 * pi) * 1/1 * L/pi * cos(theta)



How come they aren't equal? I'm definitely misunderstanding something. Is integrating using a single MC sample not the same as using a point light?

Share this post


Link to post
Share on other sites
Monte carlo is just a sampling scheme and just controls 'where you look' for lighting information. If you happen to randomly 'hit' the point that the light's coming from, that's great and you're equivalent. More problematic, however, is when your 'where you look' vector misses the point light outright and thus ignores its contribution. They control two entirely unrelated (well, at least from where you're asking) things.

EDIT: Think of the lighting information as a cubemap, if that's helpful for you. MCI is going to pick a bunch of random pixels in that to combine and get a final approximation to the lighting for the point in question.

EDIT 2: Oh, I think I see a little better now. You appear to be integrating over the entire sphere instead of just the hemisphere for equation #2. Change that, and bam, equivalent.

Share this post


Link to post
Share on other sites
For the 2nd part, 2pi is the area (sin(theta) dTheta dPhi) of integration for the hemisphere (sphere is [color=#000000][font=sans-serif][size=3]4pi[/size][/font][/color]).

Thank you for your answer. I think I have a better intuition now.

They shouldn't be the same as MC with 1 sample is not going to give you a close answer, ever, unless the integrand is constant. With a point light, the integrand is nowhere near costant. So that establishes that those 2 shouldn't be equal.

Now just need to get some intuition on why it's 2pi vs pi...

Share this post


Link to post
Share on other sites
You seem to be misinterpreting what a Monte Carlo sample is. Think of it in terms of geometry. As your ray hits a diffuse surface, it will be randomly reflected in any given direction on the hemisphere centered on the surface normal using a diffuse BRDF (which has a constant PDF of 1 / 2pi). This is what Monte-Carlo does, it sends a ray on the diffuse surface and randomly reflects it. As you increase the number of samples and average their results, the resulting radiance converges towards the correct light contribution from the point light. If you just fire one sample, it may or may not sample the point light. It's random. Monte Carlo is a random process. Point light sampling skips the whole thing and gives you the correct result (calculated analytically) corresponding to an infinite amount of MC samples. However point light sampling ignores every contribution in the scene other than the point light, while Monte-Carlo handles them correctly, which is why photorealistic path tracing must use statistical techniques because unless you only have a single point light and one diffuse surface, your integral is not going to be computable analytically - it will be nonlinear with light rays bouncing around everywhere, randomly hitting lights and surfaces. It is possible to use both in a random process to accelerate convergence, by scaling their PDF's accordingly, but it gets nontrivial with more complicated distributions (this is the simplest one).

Basically Monte-Carlo allows you to approximate any given probability density function (i.e. the integral) by randomly sampling it from a random uniform variable. In the case of a diffuse surface, the PDF happens to be extremely simple (constant), which means the integral can be calculated analytically.

Frankly I never found those analytical ways of looking at it intuitive at all. I find it all makes much more sense by looking at it from a geometric point of view with a basic understanding of optics and probability.

Share this post


Link to post
Share on other sites
Thank you for that explanation.

I think I'm getting a better intuition now. The point light formula with the 1/pi is essentially taking a full cosine weighted light integral, and then scaling that by cos(theta). The MC version is scaling each direction's contribution by cos(theta), and then averaging that.

I still gotta go reread the section about integrating punctual light sources in PBRT though. Still no intuition about the pi multiplier [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img]

Edit:
So pi is the total projected solid angle when integrating the hemisphere. That makes sense now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this