Spectral Ray Tracing

Team members: Cecilia Zhang, Ashwinlal Sreelal, Justin Comins


Soap Bubbles and Chrome Bubbles

Abstract

We want to understand the physics of colors. In this project, we built a spectral ray tracer system, by tracing rays of different wavelength sampled using the human eye’s spectrum sensitivity distribution. By modeling light dispersion we reproduced effects such as the chromatic aberrations of a lens, thin film light interference in soap bubbles, as well as temperature lights based on blackbody radiation.

We also provide our proposal link here:Project Proposal

Technical approach

Spectral Ray Tracer System

In order to build a spectral ray tracer, we want the system to take care of each ray with a single wavelength. The system first samples a wavelength and assigns it to the ray; it then traces this ray into the scene, calculates wavelength-dependent BSDF and returns a single radiance value. Intuitively a spectral ray tracer would require more samples per pixel since we need more rays to get the RGB value for a single pixel. In this project, we have three color samples so that at least 3X amount of rays are required to get a reasonably converged scene than a monochromatic ray tracer system. Following are some more details for our spectral ray tracer system.

Black Body Radiation

With the spectral ray tracer system, we are able to model light sources as objects with blackbody radiation. We follow Planck's Law:
Planck's Law
where Kb is the Boltzmann constant, h the Planck constant and c the speed of light in the medium. Therefore with a given temperature and wavelength, we are able to calculate the energy emitted by the light source. Another detail is that due to Wien's displacement law, the product of the peak wavelength and the temperature should be a constant, and thus for a specific temperature we normalize the energy by the Wien's constant calculated at that temperature.

Thin Film Rendering

There are stunning natural phenomena caused by light interference; thin film is one of them, and this effect could be rendered with our spectral ray tracer system. In this project we specifically considered soap bubble rendering, but similar effect could be seen from oil slick or a disk.

Modifying dae files

Blendr didn't like to play nicely with the .dae files we were using in our ray tracer. It would load a giant box around the scene making it difficult to edit. It may have been possible, but it was easier to edit the .dae files manually with a text editor. Inside a dae, a scene has nodes containing geometry information / transformation matrix pair along with material information. The geometry information contains a mesh of vertices and faces constructed from it, and the material information sets things like dispersion, lighting, and any extra effects like glass or chrome. Making a scene with many spheres would be easy to do, because they all have the same geometry and only transform based on position and scale, whereas making a prism would be difficult. A prism needs specific information about vertices and faces, as well as a rotation, making it a much for difficult node to create.

Results

Warm and Cold lighting

By setting temperature to 3500K (warm light) and 7500K (cool light), we are able to render our scene with different temperature atmospheres.

Cornell box under different temperature lightings (LEFT) rendered with 3500K (RIGHT) rendered with 7500K

Chromatic Aberration

Our spectral ray tracer is able to show chromatic aberration caused by lens that cannot focus lights with different wavelengths at a single point. The cornell box image on the left has this chromatic aberration effect prominently shown at the light. Since we define our focus metric as focusing the green wavelength, blue and red light is not able to be focus, and thus a mixture of the two produces a magenta-like halo around the area light on the ceiling. This effect is usually called "purple fringing" in photography. And on the right, similar effect of chromatic aberration can be seen at the scene edges.

Rendered scenes with chromatic aberration

Soap Bubbles All our rendering has 4096 samples per pixel and ray depth as 100. In both images, lens focus is on the biggest soap bubble on the right. We are able to observe some prominent light interference that produces color bands (more obvious on the later chrome bubble rendering). The reflection of the environment can also be seen from the soap bubbles.

Rendered soap bubbles
In order to observe more striking light interference at the soap bubble surface, we manually set the refraction to zero for all rays hitting the bubbles, leaving only the effect of reflections.

Notice that the right rendering has a few color leaking that causes some highlight artifacts. Under the same rendering setting (both 4096 samples per pixel and depth 100), the relative position between the environment lighting and the bubbles affect the resulting rendering quality. There might be more samples needed for the second scene to converge and be noise-free.

Chrome Bubbles

Rendered chrome bubbles

Contributions

Cecilia and Ashwin

  • Ashwin: Changed raytrace_pixel to ask for multiple ray samples for each color channel, then combined those color channels into a Specturm
  • Ashwin: Rewrote bsdfs of colored objects to return a wavelength dependent magnitude as opposed to a constant spectrum argument
  • Cecilia: Changed camera.generate ray to take in a color channel argument and sample that color channel’s wavelength distribution (Gaussian) to change the ray’s wavelength
  • Cecilia: Modified lens file and parser to include dispersion formula used for refractive index calculation
  • Cecilia: Wrote environment lighting that uses environment maps for the scene
  • Cecilia: Changed lenstester to take in wavelength dependent glass and bend lights based on different wavelengths
  • Cecilia: Changed lens_camera’s tracing through the lens to use the wavelength argument to change indices of refraction when tracing through the lens
  • Cecilia: Implemented black body radiation
  • Cecilia: Wrote the technical part and result sections of the report (Since graduate students are required to put into more details into report)
  • Ashwin/Cecilia: Refactored code so that rays have a wavelength argument that can be passed in and checked as well as that functions that return Spectrums now return a single intensity value
  • Ashwin/Cecilia: Changed sample_L of lights to have a wavelength dependent intensity to simulate different colors of lights initializizing lights with a temperature argument and modeling them as ideal black bodies to get the intensities for each color)
  • Ashwin/Cecilia: Rewrote glass bsdf to have wavelength dependent indices of refraction (similar code as lens_camera’s tracing)
  • Ashwin/Cecilia: Wrote a bubble/ thin film interference bsdf that uses wavelength, thickness and light to determine if the interference occurs (integer multiples of wavelength)

    Justin

    I mostly played a support role in this project. I didn’t affect the main pipeline directly, but one way I contributed was by helping debug in some of the later stages of the project and making design decisions with the team early. Most of how I helped the team was through providing a copius amount of .dae files. Most of them, we didn’t end up using in the presentation or even final renders. I made empty CBs, several bubble scenes, and finally a prism scene. I actually spent most of my time on this scene, trying to find the best position and angle of the prism, as well as reducing the size of the area light and making helping to make it only shine downward, like a laser. I created the prism by scratch and tranforming it with the 4x4 rotation matrix. We're thinking we didn't have enough light samples, and that's why we couldn't find anything resembling a rainbow in the scene. We have a high-sample-rate image rendering now, so the scene wasn't added to the writeup or presentation, but the bubble scenes did a good job holding their own and showing off the effects by themselves.

    References


    [1] http://refractiveindex.info
    [2] https://www.wikiwand.com/en/List_of_refractive_indices
    [3] http://www.glassner.com/
    [4] http://hyperphysics.phy-astr.gsu.edu/hbase
    [5] Morris, Nigel. "Capturing the Reflectance Model of Soap Bubbles." University of Toronto (2003).