Monday, April 15, 2013

Microfacet BSDF for Reflection and Refraction

Last year I implemented (see my blog posts here and here) a microfacet model for reflection and refraction based on the 2007 paper by Walter, Marschner, Li, and Torrance. In order to port my implementation of this BSDF to my bidirectional path tracer, I needed to add a few features and make a few fixes. In particular, I needed to scale the radiance of light that is transmitted across the interface, I needed to prevent bad reflection and refraction directions, and I needed to add the ability to evaluate the probability density of sampling a given direction. I also had to track down and fix a couple minor bugs. After making these additions and fixes, the BSDF works great.

The following images compare the results of the microfacet BSDF and a simple ideal specular BSDF. They match very closely, as they should.

Glass balls using the microfacet BSDF with very low roughness, rendered in my bidirectional path tracer.

Glass balls rendered using ideal specular reflection and refraction, rendered in Photorealizer.

Of course, the cool thing about the microfacet BSDF is that it can be used for rough surfaces, not just smooth ones. For the following image I used the microfacet BSDF for both of the glass spheres. I modulated the roughness of the left sphere (between smooth glass and ground glass) using a procedural texture map. The roughness of the right sphere is in between the two roughness values used on the left sphere.

The glass spheres use the microfacet BSDF for reflection and refraction.

Here's another image that uses this BSDF with a fairly low roughness:

The glass monkey on the right uses the microfacet BSDF for reflection and refraction.

A close-up of the rough glass monkey.

Notice that, while these images are quite smooth overall, there is still some noise in the glass objects. This is because bidirectional path tracing cannot efficiently handle tricky SDS (specular–diffuse–specular) paths (in other words, reflected and refracted caustics). I am planning on implementing MLT soon, which will allow me to better handle these types of paths.

Disney Principled BSDF

I implemented the diffuse and specular parts of the Disney "principled" BRDF (slidesnotes), a new multipurpose analytic BRDF from Walt Disney Animation Studios, created for Wreck-It Ralph and designed to match MERL measured data. The results look great. Below are a few images that I've rendered in my bidirectional path tracer using this BRDF.

For the following image I used the Disney "principled" BRDF for all of the surfaces except the two glass balls (and the lights and sensor).

An image I rendered in my bidirectional path tracer. All of the surfaces except the glass balls use the Disney "principled" BRDF.

For the following image, I used the Disney "principled" BRDF for the two monkeys in the middle, the wood and green plastic ones.

An image I rendered in my bidirectional path tracer. The wood and green plastic monkeys use the Disney "principled" BRDF.

A close-up of the wood and green plastic monkeys.

As usual, I haven't post-processed these images in any way outside my renderer, and you can click them to view them at full size.

Diffuse Reflection and Transmission BSDF

My improved BSDF system is very general and makes it really easy to add new BSDFs that contain any kind of reflection and transmission. To test this, I implemented a constant BSDF of 1/(2π). It's defined over the entire sphere, so it diffusely reflects half of the incident light and diffusely transmits the other half.

I rendered the image below in my bidirectional path tracer. The blue monkey on the left uses this new constant BSDF, giving it a soft and translucent appearance (putting a light behind the monkey would illustrate the translucency better). My next couple blog posts will describe the BSDFs I used for the other monkeys in this image.

The blue monkey on the left uses this constant-valued, reflecting and transmitting BSDF.

A close-up of the blue monkey.

Sunday, April 14, 2013

Multiple Light Sources

I added support for multiple light sources to my bidirectional path tracer. For now, when selecting an origin light for the light subpath, all of the lights are chosen with equal probability, but I will soon make the probability of selecting a particular light proportional to its total emitted power.

One light source.

Two light sources, same total power.

Two different colored light sources, same total power.

All of the Sampling Techniques for Paths of Length Two

In bidirectional path tracing, for any path of length k, there are k+2 sampling techniques. Each of these sampling techniques could be used to create exactly the same image, but certain sampling techniques are better at finding certain types of paths. We don't know ahead of time which sampling technique will be the best one for a particular scenario, so instead we use all of the sampling techniques and then combine their results using multiple importance sampling (MIS).

In my bidirectional path tracer I have implemented all of the k+2 sampling techniques for every path length k. Below are renders showing the 4 sampling techniques for paths of length 2. In the captions, s is the number of light subpath vertices in the path and t is the number of eye subpath vertices in the path.

s = 3, t = 0 (direct sensor hits)

s = 2, t = 1 (light tracing with direct sensor sampling)

s = 1, t = 2 (path tracing with direct light sampling)

s = 0, t = 3 (direct light hits)

k = 2, no MIS

k = 2, MIS (correct result but still needs a couple tweaks to be fully tuned)

Saturday, April 13, 2013

Working Bidirectional Path Tracing with MIS

I've successfully implemented bidirectional path tracing. There are still a number of optimizations and other features that I would like to implement, but most of the difficult parts are finished and the core algorithm is working correctly.

I've almost finished implementing multiple importance sampling (MIS). There's just one thing still missing from my MIS implementation: a correct PDF for sensor emission directions. This causes, for example, the contribution of light tracing to be lower than it should. I will fix this soon. For now, renders still converge to the correct result, but they converge a little more slowly than they should.

There were lots of tricky things to work though and bugs to fix along the way to this point. As of now, I've skipped over a lot of that stuff in this blog, but I might go back and add some more details later. For now, feel free to let me know if you have any questions about implementing bidirectional path tracing.

Bidirectional path tracing without MIS.

Bidirectional path tracing with MIS. Same number of samples as the image above.

Photorealizer reference (path tracing with direct illumination).