Smooth Shading with bidirectional path tracing?

Practical and theoretical implementation discussion.
Post Reply
shiqiu1105
Posts: 138
Joined: Sun May 27, 2012 4:42 pm

Smooth Shading with bidirectional path tracing?

Post by shiqiu1105 » Tue Apr 22, 2014 9:07 pm

Hi folks,

I am having trouble producing smooth shading with bidirectional path tracing(BDPT).
I am using per vertex normal, and smooth shading can be achieved with path tracing or direct lighting. However, BDPT always results in faceted looking results such as the one below.
Notice that even the caustics, which is most sampled with light tracing, are faceted.
Image

I spent some time debugging and found that this faceted look was the result of the sampling technique that connects light samples directly to the camera.
I really don't know how to fix this, since these samples are sampled from light source, and they depend only on the geometry, not normal.
The following is a pure light tracing image. All samples are traced from the light source and then projected to camera.
sphere.jpg
sphere.jpg (163.14 KiB) Viewed 8479 times
All meshes in the above image uses per-vertex normal.
But it confuses me that mitsuba seems to be free from this artifact.
Any clue?

beason
Posts: 52
Joined: Sat Dec 10, 2011 1:58 am
Location: Los Angeles, CA

Re: Smooth Shading with bidirectional path tracing?

Post by beason » Tue Apr 22, 2014 10:54 pm

Veach's thesis discusses issues with bidirectional methods and smoothed normals, have you seen that...?

shiqiu1105
Posts: 138
Joined: Sun May 27, 2012 4:42 pm

Re: Smooth Shading with bidirectional path tracing?

Post by shiqiu1105 » Tue Apr 22, 2014 11:07 pm

beason wrote:Veach's thesis discusses issues with bidirectional methods and smoothed normals, have you seen that...?
Actually I haven't. Would you mind telling me which chapter in which he talks about that?

shiqiu1105
Posts: 138
Joined: Sun May 27, 2012 4:42 pm

Re: Smooth Shading with bidirectional path tracing?

Post by shiqiu1105 » Tue Apr 22, 2014 11:24 pm

I found it. It's in section 5.3.
I haven't read the details, if anybody knows what's happening please explain it here too so that we can all learn.

I will read it first.

What a great thesis, always can learn new things from it. No wonder he won the Oscar...

Dade
Posts: 206
Joined: Fri Dec 02, 2011 8:00 am

Re: Smooth Shading with bidirectional path tracing?

Post by Dade » Wed Apr 23, 2014 8:19 am

shiqiu1105 wrote:I found it. It's in section 5.3.
I haven't read the details, if anybody knows what's happening please explain it here too so that we can all learn.

I will read it first.

What a great thesis, always can learn new things from it. No wonder he won the Oscar...
The problem is presented in section 3.7.5: normal interpolation makes your BSDF no symmetrical and you have to use adjoint BSDF to solve the problem as explained in section 5.3. All the chapter 5 is dedicated to the cause and the solution of this problem.

shiqiu1105
Posts: 138
Joined: Sun May 27, 2012 4:42 pm

Re: Smooth Shading with bidirectional path tracing?

Post by shiqiu1105 » Mon Apr 28, 2014 9:57 pm

Dade wrote:
shiqiu1105 wrote:I found it. It's in section 5.3.
I haven't read the details, if anybody knows what's happening please explain it here too so that we can all learn.

I will read it first.

What a great thesis, always can learn new things from it. No wonder he won the Oscar...
The problem is presented in section 3.7.5: normal interpolation makes your BSDF no symmetrical and you have to use adjoint BSDF to solve the problem as explained in section 5.3. All the chapter 5 is dedicated to the cause and the solution of this problem.
I read the section and whipped up a quick fix in my BDPT implementation where light vertices are connected explicitly to the sensor. And this fixed the faceted looks. However I am more confused about the problem in general. I tried to use this adjoint BSDF for all light path (not only when connecting to the sensor, but also when connecting with camera path), but obvious error would occur.

And I don't see pbrt mentioning this in its implementation of MLT or photon mapping. I did see Mitsuba implemented this, in the PathVertex::sampleNext() function, however its implementation it's quite tricky to follow and I failed to match it with Veach's thesis.

I think this shading normal problem really makes the light transport framework more messed up. If only there is a good illustration on how to do it correctly.

shiqiu1105
Posts: 138
Joined: Sun May 27, 2012 4:42 pm

Re: Smooth Shading with bidirectional path tracing?

Post by shiqiu1105 » Mon Apr 28, 2014 11:15 pm

Additionally, Veach says when tracing importance from the light source, local bsdf sampling should happen based on the cosine term of the geometry normal.
I took a quick glance at the mitsuba source code, and it looks to me that it's always sampling based on shading normal too.

shocker_0x15
Posts: 75
Joined: Sun Aug 19, 2012 3:24 pm
Contact:

Re: Smooth Shading with bidirectional path tracing?

Post by shocker_0x15 » Wed May 21, 2014 11:50 am

Hi.

I have implemented the correction of non-symmetrical BSDF problem due to shading normal.

First, sampling a direction not according to a geometry normal when we focus on adjoint BSDF is not problem for convergence.
(as long as we can sample all directions wherever a BSDF value is not zero)

You have to consider a correction factor for all vertices related to light-path.
In BPT, one considers a case where a path is constructed by more light-path sampling.
So, in case you determine Russian roulette probability by using MC throughput (fs * cos / pdf), you have to take adjoint correction into consideration.
As you think, this makes the algorithm messy, but I think it is inevitable because shading normal doesn't have a physical basis.
Furthermore, adjoint correction factor |(dot(wo, Ns) * dot(wi, Ng)) / (dot(wo, Ng) * dot(wi, Ns))| has singularity, so you need to also take care of this.

What you have to pay attention to is the order of the numerator and denominator of the factor.
BcVi0jiCQAMzudF.png
BcVi0jiCQAMzudF.png (687.38 KiB) Viewed 7973 times
* When you implement the BPT algorithm based on PBRT, you should disable texture filtering used by a ray traced from a camera, because it makes BSDF non-symmetric.

Post Reply