Sunday, April 9, 2017

Email reply on BRDF math

I got some email asking about using BRDFs in a path tracer and thought my reply might be helpful to those learning path tracing.

Each ray tracing toolkit does this a little differently.   But they all have the same pattern:

color = BRDF(random direction) * cosine / pdf(random direction)

The complications are:

0. That formula comes from Monte Carlo integration, which is a bit to wrap your mind around.

1. The units of the BRDF are a bit odd, and it's defined as a function over the sphere cross sphere which is confusing

2. pdf() is a function of direction and is somewhat arbitrary, through you get noise if it is kind of like the BDRF in shape.

3. Even once you know what pdf() is for a given BRDF, you need to be able to generate random_direction so that it is distributed like pdf

Those 4 together are a bit overwhelming.   So if you are in this for the long haul, I think you just need to really grind through it all.   #0 is best absorbed in 1D first, then 2D, then graduate to the sphere. 

3 comments:

  1. Pete,

    It is even more complicated than that, right? It might even depend on the exact parameterization you use for the hemisphere. That might give you an additional sin term, or something else.

    ReplyDelete
  2. Phil, kind of. Generally speaking, that particular complexity is part of the "BRDF" factor.

    The BRDF is a function of the incoming and outgoing directions, but only when those directions are expressed in a local coordinate system. It's that "local coordinates" aspect that is responsible for a lot of the complexity in real BRDFs.

    ReplyDelete
  3. I would like to appreciate your work and would like to tell to my friends.
    Graphiste Grenoble

    ReplyDelete