View on GitHub

Cardinal3D

Stanford CS248A (Assignments 2 and 3)

(Task 6) Materials

Now that you have implemented the ability to sample more complex light paths, it’s finally time to add support for more types of materials (other than the fully Lambertian material that you have implemented in Task 5). In this task you will add support for two types of materials: a perfect mirror and glass (a material featuring both specular reflection and transmittance) in student/bsdf.cpp.

To get started take a look at the BSDF interface in rays/bsdf.h. There are a number of key methods you should understand in BSDF class:

There are also two helper functions in the BSDF class in student/bsdf.cpp that you will need to implement:

Step 1: Perfect Mirror Surfaces

Implement the class BSDF_Mirror which represents a material with perfect specular reflection (a perfect mirror). You should Implement BSDF_Mirror::sample, BSDF_Mirror::evaluate, and reflect. (Hint: what should the pdf sampled by BSDF_Mirror::sample be? What should the reflectance function BSDF_Mirror::evaluate be? )

Step 2: Transmissive Surfaces (EXTRA CREDIT)

Implement the class BSDF_Glass which is a glass-like material that both reflects light and transmit light. As discussed in class. the fraction of light that is reflected and transmitted through glass is given by the dielectric Fresnel equations.

Specifically your implementation should:

Dielectrics and Transmission (for the extra credit)

Fresnel Equations for Dielectric

The Fresnel Equations (another link here) describe the amount of reflection from a surface. The description below is an approximation for dielectric materials (materials that don’t conduct electricity). In this assignment you’re asked to implement a glass material, which is a dielectric.

In the description below, and refer to the index of refraction of the medium containing an incoming ray, and the zenith angle of the ray to the surface of a new medium. and refer to the index of refraction of the new medium and the angle to the surface normal of a transmitted ray.

The Fresnel equations state that reflection from a surface is a function of the surface’s index of refraction, as well as the polarity of the incoming light. Since our renderer doesn’t account for polarity, we’ll apply a common approximation of averaging the reflectance of polarizes light in perpendicular and parallel polarized light:

The parallel and perpendicular terms are given by:

Therefore, for a dielectric material, the fraction of reflected light will be given by , and the amount of transmitted light will be given by .

Alternatively, you may compute using Schlick’s approximation.

Distribution Function for Transmitted Light

We described the BRDF for perfect specular reflection in class, however we did not discuss the distribution function for transmitted light. Since refraction “spreads” or “condenses” a beam, unlike perfect reflection, the radiance along the ray changes due to a refraction event. In your assignment you should use Snell’s Law to compute the direction of refraction rays, and use the distribution function given in section 8.2 of Pharr, Jakob, and and Humphries’s book Physically Based Rendering for transmission and reflectance from a glass surface. See the book for a derivation based on Snell’s Law and the relation . (But you are more than welcome to attempt a derivation on your own!)

When you are done, you will be able to render images like these:

cornell_classic