Veach thesis - formula question

Practical and theoretical implementation discussion.
graphicsMan
Posts: 164
Joined: Mon Nov 28, 2011 7:28 pm

Re: Veach thesis - formula question

Post by graphicsMan » Wed Jul 18, 2012 1:31 pm

I'm slighty confused. Are you connecting x1 and x2 with an edge? In either case it looks like L for x2 is incorrect... you're missing the other cosine in the geometry term.

spectral
Posts: 382
Joined: Wed Nov 30, 2011 2:27 pm
Contact:

Re: Veach thesis - formula question

Post by spectral » Wed Jul 18, 2012 1:51 pm

graphicsMan wrote:I'm slighty confused. Are you connecting x1 and x2 with an edge? In either case it looks like L for x2 is incorrect... you're missing the other cosine in the geometry term.
1) I use the geometric term to convert the emitter radiance (Watts/m²/sr) to the x1 irradiance (Watts/m²)
2) Once I have the light on x1, to compute the light on L2 I simply apply the rendering equation http://en.wikipedia.org/wiki/Rendering_equation : L2 = L1 * f/p * |N2.Wi2|

Why should I apply a geometric term at x1 ? where G = |N1.-W2| I suppose
Spectral
OMPF 2 global moderator

graphicsMan
Posts: 164
Joined: Mon Nov 28, 2011 7:28 pm

Re: Veach thesis - formula question

Post by graphicsMan » Wed Jul 18, 2012 2:55 pm

maybe I just misunderstood your diagram. when you sample surfaces directly, you have to use the integral with measure area, while when sampling directions, you use the one with measure solid angle.

When you're in one (sampling directions), and you sample, say, a light source, or a surface (or VPL), you have to perform a change of measure, which is what all that geometry term stuff is about. Sorry, in a bit of a hurry to get more detailed than that now...

spectral
Posts: 382
Joined: Wed Nov 30, 2011 2:27 pm
Contact:

Re: Veach thesis - formula question

Post by spectral » Wed Jul 18, 2012 3:07 pm

Thanks,

It is not what I do when I use the following formula ?

L = Le * |Nl.-Wi1| |N1.Wi1| / r*r

Where :
x0 : point on light
x1 : first hit
r : distance(x0,x1)
Nl : normal at x0
N1: normal at x1
Wi1= normalize(x0-x1)

First, I choose a random point on the light and a random (hemisphere) direction, then I convert it with this formula, only one time ?
Spectral
OMPF 2 global moderator

graphicsMan
Posts: 164
Joined: Mon Nov 28, 2011 7:28 pm

Re: Veach thesis - formula question

Post by graphicsMan » Wed Jul 18, 2012 4:24 pm

Depends... is this for generating a new position x1 (determined by x0 and Wi1), or is this sampling the light point x0 to light at a predetermined location x1? For the latter, yes, this is correct.

apaffy
Posts: 46
Joined: Thu Dec 01, 2011 11:00 pm
Location: UK
Contact:

Re: Veach thesis - formula question

Post by apaffy » Wed Jul 18, 2012 4:48 pm

spectral wrote:Thanks,

It is not what I do when I use the following formula ?

L = Le * |Nl.-Wi1| |N1.Wi1| / r*r

Where :
x0 : point on light
x1 : first hit
r : distance(x0,x1)
Nl : normal at x0
N1: normal at x1
Wi1= normalize(x0-x1)

First, I choose a random point on the light and a random (hemisphere) direction, then I convert it with this formula, only one time ?
To add a bit more context from graphicsMan, what you have computed above is part of the contribution of the path. However, we're doing Monte Carlo integration here, where what we want is the contribution of the path divided by its probability density. In your equation above, you've basically taken the energy emitted by some differential area at x0, then used the geometry term to compute the energy received by some differential area at x1. However, when you divide through by the probability density of the path, this geometry term will cancel with the geometry term involved with converting your solid angle pdf at x0 (which you computed when sampling the outgoing light direction) into a probability density wrt area at x1.

To be explicit about what you compute in the Veach framework for your scenario, where you have an eye subpath x3x2 connected with a light subpath x0x1:

You sample x0 with some pdf wrt area P_A(x0). You sample the emission function at x0 with some projected solid angle pdf P(x0 -> x1), fire a ray and hit x1. For cosine-weighted sampling this pdf 1. If you have a pdf wrt to solid angle just divide it by cos(theta) to get the pdf wrt projected solid angle.
You sample x3 at the camera with some pdf P_A(x3). You sample the importance function at x3 with some projected solid angle pdf P(x3 -> x2), fire a ray and hit x2.

Assuming I've not made any silly mistakes putting this post together, your Monte Carlo sample (i.e. path contribution divided by pdf) should be:

F = (Le(x0 -> x1) * f(x0 -> x1 -> x2) * G(x1 <-> x2) * f(x3 -> x2 -> x1) * We(x3 -> x2)) / (P_A(x0) * P(x0 -> x1) * P(x3 -> x2) * P_A(x3))

ingenious
Posts: 282
Joined: Mon Nov 28, 2011 11:11 pm
Location: London, UK
Contact:

Re: Veach thesis - formula question

Post by ingenious » Wed Jul 18, 2012 6:00 pm

We already discussed Veach's framework. If you want to go bidirectional, you just have to switch your mindset to this framework. Be sure that you understand the framework as well as possible by experimenting on paper, and then a correct implementation is trivial.

And again I want to express my wondering that people simply don't appreciate the greatness of this framework. Now read the following carefully and at least 3 times. Yes, seriously. At least 3 times:

The greatness of this framework is that the sampling primitive it works with is a full light path that connects the eye to a light source. It also makes a strict separation between the radiance contribution of a path and its sampling density. This is crucial for the application of multiple importance sampling for bidirectional path tracing, and lays the ground for Metropolis Light Transport. The contribution of a path is fixed and never changes. It is the measurement contribution function that we discussed before, which includes geometric factors for *all* edges on the path - nice and symmetric!

The only thing that changes is the path sampling pdf, depending on what technique you use to construct it. This path pdf is a product of the pdfs of each path vertex, each of which is *always* expressed w.r.t. area density. If you continue a path using hemispherical sampling (i.e. random walk), once you hit a surface and create the next path vertex, you immediately convert the sampling density from solid angle to area. This conversion means simply multiplying by a "cos / dist^2" term. Read the chapter in the thesis (I gave a page number before) that describes this factor, draw it on paper, and try to understand this factor.

And now what happens in bidirectional path tracing: You trace one sub-path from each end, and every edge on these sub-paths ends up having this conversion factor. When you connect the endpoints of the sub-paths, this is the only edge that *does not* get such a factor. Why? Because everything is deterministic there - the endpoint have already been sampled, and there's no *new* random decision in this connection.

So what happens *in the end*? And I repeat *in the end* - mathematically, only in the end do you divide the path radiance contribution and the path pdf to obtain an estimate. So what happens is that many geometric terms cancel out, except the ones involved in the connection edge - only for this edge you get the inverse squared distance in the final estimator. And this is the cause for the famous singularity with virtual point light methods.

My recommendation:
1) Turn off your PC
2) Get a pen and a sheet of paper
3) Draw a light path of some length, put the associated radiance contribution terms next to each element of the path
4) Observe what you've drawn, look at the *beautiful symmetry*, appreciate how nice the path contribution looks Le - G - f - G - f - G - We
5) Once you have a good understanding of the path contribution, redraw the path two more times
6) Think of two possible ways to sample this path bidirectionally, and put the path pdf terms associated with the vertices and edges on each drawing
7) Observe then which terms cancel out when you divide the contribution of the path by each path pdf
8) Say out loud "Eureka! Eric, you're the man!"
9) Come back here and share the excitement ;)

P.S. Once I did the above, I realized why I was so much confused and disappointed by the Advanced Global Illumination book. It deals with a bunch of useless concepts like importance distribution and GRDF, and mentions the path integral on half a page! The bias of the book authors toward their own work has ruined the whole book. It goes into so much detail in radiosity and density estimation, and completely ignores all contributions of Eric Veach, which in my opinion are some of the most fundamental ones. Hell, he's probably the only rendering guy who's work can contribute back to the fields everybody has been borrowing Siggraph material from :!:

P.P.S. Sorry for my attitude, I get emotional sometimes :) Cheers! I hope I managed to help, in spire of all the ranting.
Image Click here. You'll thank me later.

apaffy
Posts: 46
Joined: Thu Dec 01, 2011 11:00 pm
Location: UK
Contact:

Re: Veach thesis - formula question

Post by apaffy » Wed Jul 18, 2012 6:36 pm

+1 to ingenious' post.

I agree you just have to work through the maths yourself until it all slots into place. For me the Eureka moments were:
* Understanding how the geometry term is used to convert pdfs between projected solid angle and area
* Understanding how all but one of the geometry terms cancel between the path contribution and its (path) pdf

ingenious
Posts: 282
Joined: Mon Nov 28, 2011 11:11 pm
Location: London, UK
Contact:

Re: Veach thesis - formula question

Post by ingenious » Wed Jul 18, 2012 7:33 pm

apaffy wrote:* Understanding how the geometry term is used to convert pdfs between projected solid angle and area
* Understanding how all but one of the geometry terms cancel between the path contribution and its (path) pdf
* How super elegantly multiple importance sampling solves the notorious singularity in short path connections, which has been "researched" by so many people, many of whom still don't understand/appreciate this solution
Image Click here. You'll thank me later.

Igors
Posts: 17
Joined: Sat Jan 07, 2012 11:56 am

Re: Veach thesis - formula question

Post by Igors » Thu Jul 19, 2012 7:48 am

spectral wrote: L = Le * |Nl.-Wi1| |N1.Wi1| / r*r
This is a lighting coming from area 1.0. That can correspond to a small or large solid angle. But I don't understand how to integrate. If we get some rays and connect something - it does not mean yet all incoming directions are covered
apaffy wrote: * Understanding how the geometry term is used to convert pdfs between projected solid angle and area
I've not this understanding and would be interested in explanations if possible

Thanks

Post Reply