Page **5** of **9**

### Re: Veach thesis - formula question

Posted: **Thu Jul 19, 2012 8:59 am**

by **apaffy**

Igors wrote: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

I think the best I can do is direct you towards sections 8.1 and 8.2 of the Veach thesis, which covers this topic in detail.

Section 8.1 shows the geometric relationship between differential projected solid angle and differential area (equation (8.2)).

Section 8.2 uses this to convert between pdf wrt projected solid angle at x to pdf wrt area at x' (last equation in section 8.2).

### Re: Veach thesis - formula question

Posted: **Thu Jul 19, 2012 9:40 am**

by **spectral**

Igors wrote: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

Not only, it is simply the "G" (geometric term). Le can come from a larger area. But in general it is used for dA (unit differential area).

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

[/quote]

Take a look at the paper "A Survey of Importance Sampling Applications in Unbiased", it is explained in section (3.4)

### Re: Veach thesis - formula question

Posted: **Thu Jul 19, 2012 9:40 pm**

by **spectral**

Thanks for all your comments...

I'm currently reading the Dietger document and also I use the Veach thesis... as proposed by Ingenious I do everything in paper. So,

I have see in the Veach thesis (page 228) the following formula to convert a pdf from directional to area.

- UnitConversion.png (18.94 KiB) Viewed 5798 times

When I have the following formula and apply the conversion, I got the following result :

- UnitConversion2.png (4.32 KiB) Viewed 5779 times

Just to compare to my path tracer, where I use the following formula :

- UnitConversion3.png (1.35 KiB) Viewed 5779 times

Does someone can explain please ?

Thanks in advance

### Re: Veach thesis - formula question

Posted: **Thu Jul 19, 2012 11:15 pm**

by **ingenious**

Check your formulas again. They're also quite hard to understand with the short notation you've used - only you can tell what the terms mean

In your path tracer you should be multiplying with the cosine between the normal at the current point and the sampled scattering direction. The cosine that cancels out in the area integration formulation is the other cosine - at the surface where you land. And you never consider this cosine explicitly in your path tracer. Which is actually quite unintuitive in the solid angle formulation - why do you multiply by the outgoing cosine but not with the incoming? Fortunately, with Veach's area formulation, it's clearly visible that this discrepancy is due to the path sampling procedure, which makes some terms cancel out - the path contribution is still symmetric, as it's independent on how the path has been sampled. Furthermore, if you were to choose some arbitrary point in space and use it as a vertex on a path, it'd be trickier (though possible) to explain what happens with the estimator for that path in the solid angle integration formulation.

### Re: Veach thesis - formula question

Posted: **Fri Jul 20, 2012 7:08 am**

by **spectral**

Right,

I have rewrite my equation in a more clear form

sorry... I have update the pictures.

What I don't understand is why I got the other cosinus in my caculus !

### Re: Veach thesis - formula question

Posted: **Fri Jul 20, 2012 8:27 am**

by **apaffy**

Hi spectral,

Firstly, in the "UnitConversion.png" diagram, p(w_o) is actually pdf wrt solid angle. This is why the equation has a missing cosine in this diagram.

You can convert this to projected solid angle (let's call this p_\perp) as follows (paste into LaTeX to see this in a nice form - as an aside having something like MathJax on this forum would really help):

p_\perp(w_o) = p(w_o) / |cos(\theta_o)|

If you plug this into the units conversion equation you get:

p_A(x')

= p_\perp(w_o) |cos(\theta_o)| |cos(\theta'_i)| / ||x - x'||^2

= p_\perp(w_o) G(x <-> x')

Note that we had to use pdf wrt *projected* solid angle to make everything nicely symmetric and be able to use the G term. This now matches the equation at the end of section 8.2 as I posted earlier.

Your next diagram "UnitConversion2.png" doesn't make any sense, please explain what you are trying to do here.

In your final diagram "UnitConversion3.png", I think you are showing some part of the Monte Carlo term (i.e. path contribution over path pdf) as you extend the path, but if so I'd expect you use w_i not w_o (since in a path tracer you are always sampling w_i).

I'm going make a guess I and assume that the p(w_i) in this equation of yours is wrt solid angle, in which case the cosine is present because your pdf is wrt solid angle, but you actually need to sample wrt projected solid angle when path tracing, i.e:

F = f(x') / p_\perp(w_i) = f(x') |cos(\theta_i)| / p(w_i)

Hope that helps! (As another aside, whenever people write a pdf, I wish they'd be completely clear what the measure is for this term i.e. area/solid angle/projected solid angle.)

### Re: Veach thesis - formula question

Posted: **Fri Jul 20, 2012 10:51 am**

by **spectral**

Right,

I have to use Wi and not Wo because I sample x' and not x ! Thanks for the clarifications... it become clear

So, finally I'm back to my code, just to test what I've learned... and I'm surprised that the code is now even easier, simplified !

I even find this beautiful symmetry in my code

(this will be great to improve coherence on the GPU !!)

Please, let me try to solve the following example :

- bdpt_example.png (12.02 KiB) Viewed 5761 times

I solved it this way :

- bdpt_solve.png (7.22 KiB) Viewed 5761 times

Can you tell me if it is correct, just to check that I have understand ?

### Re: Veach thesis - formula question

Posted: **Fri Jul 20, 2012 11:49 am**

by **apaffy**

Hi spectral, glad to hear things are starting to get more clear. Your diagram is a great start, but I don't agree with your equation for the final Monte Carlo sample.

As ingenious posted above, what you need to write down is:

* The path contribution. This has great symmetry being Le G f G f G f G f G We (for your path with 6 vertices), and is independent of how it was sampled.

* The path pdf. This is also greatly symmtric being P_A(x0) P_A(x1) ... P_A(x5)

You then divide the two to get the sample value. What you need to do is:

* Convert all the interior area pdf terms of path pdf into projected solid angle pdf (using the geometry term in the formulae in previous posts). For example using P_A(x4) == P_\perp(x5 -> x4) G(x5 <-> x4).

* Let the geometry terms cancel out for efficiency

You'll end up with an equation that contains:

* Le(x0->x1) and We(x5->x4)

* f for all interior vertices

* P_A(x0) and P_A(x5)

* P_\perp for x0->x1, x1->x2, x5->x4 and x4->x3 (or if you want to use pdf wrt solid angle, P(x -> x') for these cases and some cosine factors)

* The geometry term just for G(x2 <-> x3)

I won't spoil the fun by just writing down the answer.

### Re: Veach thesis - formula question

Posted: **Fri Jul 20, 2012 11:58 am**

by **apaffy**

Also please when you write "pdf" state the measure. For example:

Path space pdf = pdf wrt area product measure

P_A(x) = pdf wrt area at x

P(x -> x') = pdf wrt solid angle of ray x->x' at x

P_\perp(x -> x') = pdf wrt projected solid angle of ray x->x' at x

This really helps to not lose track of what's going on!

### Re: Veach thesis - formula question

Posted: **Fri Jul 20, 2012 1:53 pm**

by **spectral**

Thanks,

So , I have retry and got this solution. But I have some doubts about the value of p(x0->x1) and p(x4->x5).

Can you clarify please ?

- bdpt_solve2.png (14.65 KiB) Viewed 5740 times