## Bidirectional path tracing in the layered mat

Discussion related to the implementation of new features & algorithms to the Core Engine.

Moderators: jromang, tomb, zcott, coordinators

### Bidirectional path tracing in the layered mat

I'm adding bi-dir to the layered mat to try and improve the behaviour, but I have a few questions that I'm having trouble finding the answers to. And yes, I've read both the Veach and LaFortune papers

So here's what i'm planning to do - if anyone spots any huge flaws can they point them out?

1) calculate two paths using the BSDF sample methods, one for the light and one for the eye. I'm currently terminating the path if it exits the material or exceeds a set number of bounces (i'll add in russian roulette or something later)

2) To constuct sub-paths I go through layer by layer and connect every part of the eye path with every part of the light path that reach that layer - so effectively my visibility test is (path vertices in same layer) ? 1: 0

3) Given a valid subpath I calculate the total f for that subpath.

4) To calculate the probability of that path being sampled I start with i (from 0 to path length):
4a) accumulate the individual sampling pdfs (multiply) with the first i probabilities from the forward pdf, and the next (pathlength -1) probabilities from the backward pdf
4b) sum these (n=pathlength) individual probabilities to get the final pdf

5) Then I sum f/pdf for each of the subpaths

6) finally I convert the final value from f to F

paco

Posts: 456
Joined: Sun Feb 07, 2010 1:37 am

### Re: Bidirectional path tracing in the layered mat

Hi,

Looks ok to me, but you don't treat pass through materials specially, that might make some materials pretty difficult to render.

Jeanphi
jeanphi

Posts: 6624
Joined: Mon Jan 14, 2008 7:21 am

### Re: Bidirectional path tracing in the layered mat

you don't treat pass through materials specially

I'm not sure what you mean... do you just mean materials that are mixed with a null, general transmissive materials, or specular transmissive materials? I must admit I thought that bidir handled all of those (via the sample method)?
paco

Posts: 456
Joined: Sun Feb 07, 2010 1:37 am

### Re: Bidirectional path tracing in the layered mat

paco wrote:I'm not sure what you mean... do you just mean materials that are mixed with a null, general transmissive materials, or specular transmissive materials? I must admit I thought that bidir handled all of those (via the sample method)?

Never mind, it won't make a difference since you only connect eye and light paths on the same layer.

Jeanphi
jeanphi

Posts: 6624
Joined: Mon Jan 14, 2008 7:21 am

### Re: Bidirectional path tracing in the layered mat

Actually I'm thinking of going back to simple path as I currently use - the bidir implementation above doesn't handle a specular surface well due to having to call F() when connecting paths (which is 0 for specular) whereas path consistently uses the sampleF() method which can handle that.
paco

Posts: 456
Joined: Sun Feb 07, 2010 1:37 am

### Re: Bidirectional path tracing in the layered mat

paco wrote:Actually I'm thinking of going back to simple path as I currently use - the bidir implementation above doesn't handle a specular surface well due to having to call F() when connecting paths (which is 0 for specular) whereas path consistently uses the sampleF() method which can handle that.

Using only path tracing will prevent things to work correctly in the presence of specular layers: if you have a specular layer on top of a diffuse layer for example, you won't be able to compute F with just path tracing while bidir will be able to handle it. You might also face efficiency issues with highly glossy layers.

Jeanphi
jeanphi

Posts: 6624
Joined: Mon Jan 14, 2008 7:21 am

### Re: Bidirectional path tracing in the layered mat

Hmm... good point. Will have another look at how the normal 3D bidir handles specular surfaces.
paco

Posts: 456
Joined: Sun Feb 07, 2010 1:37 am