Rendering Algorithms - Final Project - Srinath Ravichandran

Theme

The theme for the this year's rendering competition is "Contrast". I would like to quote a line that I read on the internet. 'Our sensation is the most intense where two extremes are juxtaposed'. I decided to approach this problem by first looking through the internet to find images that seemingly had this concept very vivident in them. I chose the following two images initially because they had a variety of interesting things in them that I decided would be very good to render.

Initial Inspirational Image 1

Initial Inspirational Image 2

The images were taken from the devianart website (http://edotistical-tokyo.deviantart.com/blog/). However while undertaking the project, I found that rendering a scene similar to these would be very difficult. In addition to modelling the scene, texturing and scene composition were turning out to be very difficult. Hence I decided to modify the scene that I wanted to render. I found the following image that was visually very arresting as well as comparatively easy to model and light. .

Inspirational Image

The above image was taken from the Flikr website. The above image has the theme of contrast at multiple levels. Lighting is very contrasting here since only one part of the image is focussed heavily while the rest of the image is dark. Second the idea that two battling parties on the chess board has agreed upon to line up and acknowledge one 'true king' is also very contrasting. Hence I decided to undertake the challenge of rendering the same setting. Some of the important visual features in the image are described below.

Major Visual Features

  • Stark lighting differences
  • Depth of Field
  • Shiny materials
  • I decided to add a couple of additional features to accentuate the mood further in trying to recreate this image in my renderer. I decided to add volumetric effects that gave a sense of 'awe' as the king arrived before the warring parties. Plus I decided to use different materials for all three parties in the scene.

    Additional Planned Features

  • Volumetric effects
  • Different materials



  • Implemented Features

    Simple Features

    Depth of field(2 pts)

    Depth of field provides increased realism for making the viewer pay attention to a part of the scene. Pinhole cameras generally have infinite focal length since all parts in the scene are in perfect focus. However real life cameras employ lens systems that enable to have depth of field as well as bokeh effects. Depth of field is achieved by providing a focal length and lens radius to the camera definition. During rendering, a sample point is chosen on the lens and a corresponding ray for each pixel is chosen through that point.

    Validation

    In order to validate the correctness of the depth of field implementation, I created a test scene with exact units known. The scene had 4 perpendicular planes at exact distances from the camera. The depth of field was then set to each particular plane's distance from the camera. During rendering only those planes that are at the exact focal length should be in perfect focus. Other planes would be blurred depending upon the lens radius.

    Focal length : 5 meters Focal length : 6 meters Focal length : 7 meters Focal length : 8 meters

    Source file : Perspective.cpp

    Texture support(2 pts)

    I have added texture mapping within the renderer to apply image textures as well as use roughness maps for various BSDFs implemented within the renderer. Currently only UV mapped texturing is supported. The texturing code employs currently nearest neighbour interpolation. Bilinear interpolation code is also implemented. All the texture sampling code in the renderer employ the nearest neighbour interpolation.

    Source file : Bitmap.cpp

    Moderate Features

    Environment Lights (6 pts)

    Environment lights enable employing HDRI images taken from different environments to provide lighting information for scenes. This allows us to set the mood of the scene by choosing different environment maps. The following image is a scaled down version of a HDRI map(to better show regions of high intensity).

    Scaled Environment Map Sampled Environment Map

    The environment map is sampled by first constructing a 2dimensional pdf over the entire image. First a conditional distribution is computed for each scan line of the image and then a marginal is computed for all the conditional distributions. Given a 2d random sample, first a scan line is chosen by using the marginal and then the corresponding pixel in the image is sampled by the conditional. The sampled texture coordinates are in latitude-longitude format. They are converted to spherical directions which describe the direction from which light enters the scene. The following test scene was illuminated using the above shown environment map.

    Environment Lit Scene

    Source file : Environmentlight.cpp

    New BSDFs(6 pts)

    In order to increase the variety of materials that my renderer can handle, I've implemented a couple of new BSDFs. These are primarily microfacet based models. I've implemented additional distribution functions based on the GGX and Phong model by following the paper (Microfacet models for refraction through rough surfaces). I implemented the sampling routines for these new distribution functions as well as their corresponding Smith Functions for the (G) terms. I validated the distribution functions by checking the implementations by using the warptest application. The results of the tests for various functions are shown below.

    GGX sampling

    GGX sampling tests

    Phong sampling

    Phong sampling tests

    With these new distribution functions in place, I proceeded ahead to implement three additional BSDF types. They are smooth conductor, rough conductor and rough dielectric. The rough conductor and the rough dielectric employ the new distribution functions. Their roughness values can be parameterized using textures too. Below are the results of implementing the BSDFs and comparing them with Mitsuba renderings. Note that the scenes will be slightly offset with respect to view location and environment mapping orientation. Other than that the material should look consistent in both cases.

    Smooth Conductor

    Mitsuba Smooth Conductor

    Rough Conductor

    Mitsuba Rough Conductor

    Rough Dielectric

    Mitsuba Rough Dielectric

    My implementation of the rough dielectric is buggy. I am consistently losing energy with subsequent bounces inside the dielectric medium and hence more darker than it should be.


    Source files : smoothconductor.cpp, roughconductor.cpp, roughdielectric.cpp


    Advanced Features

    Homogeneous Volumetric Path Tracing(8 pts)

    I have implemented volumetric path tracing in homogeneous media with support for isotropic and anisotropic phase functions. I've implemented the Henyey-Greenstein phase function which can help produce forward and backward scattering effects. I first implemented a single scattering volumetric path tracer to make sure that I am not missing any terms and that I can effectively importance sample both the light and the phase function in the scattering location.

    Single Scattering

    When I was confident that the implementation was working fine, I proceeded ahead to implement multiple scattering volumetric path tracer. My implementation keeps the branching count low by sampling either the medium interaction or the surface interaction. If a medium interaction happened, MIS was employed between emitter sampling and phase sampling to get attenuated direct lighting term at the scatter location. Then the phase function was sampled to generate the next bounce direction from the media. If a surface interaction happened, then attenuated direct lighting for the surface is computed. Once the direct lighting term was added to path contribution, the next bounce ray was sampled using the BSDF (basic path tracing) and the traversal continues until a fixed depth or path terminates due to russian roulette.

    Multiple Scattering

    Source files : volpath_singlescattering.cpp, volpath.cpp


    Final Rendering Competition Submission

    For the rendering competition submission, I designed the scene myself from scratch. I downloaded the chess pieces from the internet(Blendswap site) and arranged them in a manner that allowed me to reproduce the inspirational image. The entire scene is within a diffuse environment(gray) to highlight the contrast differences between dark and light. Each chess piece sits on a highly glossy microfacet piece that helps to reflect light from the emitter onto the chess piece itself (strong bounce light). The black pawns have a glossy BSDF where as the white pieces have a rough conductor BSDF(silver). The king himself is modeled using gold(to highlight the arrival of a new king and not the usual black and white kings). I also wanted the king to exhibit royalty (and hence the sparkly gold). I wanted to set the atmosphere so that the light highlights the king more than the other pieces and hence used a volumetric medium that spanned the entire scene and had an absorption coefficient higher than the scattering coefficient. Finally the entire scene was illuminated by one light source above and slightly offset to the king. The camera had its focal length set to the king piece and hence a nice depth of focus was achieved. The final image is as follows.


    I used GIMP to add a soft glow to make the image even more nicer. The result is given below.

    Final Submission

    I am a huge game of thrones fan and decided to add the iron throne in the background. I thought it would be fun to add this element to the theme. I downloaded the throne from blendswap website and gave it a rough copper appearance (in the novels the iron throne is made of melted swords. Copper looked nice here in this setting though). The resulting image too had a lot of fireflies which could be cleared with a help of a denoiser. I manually filtered the pixels using GIMP and added a nice glow to it. Note that this is not my official submission. The image without the throne (which closely resembles the inspirational image) is the actual submission to the competition.


    Adding the glow


    Credits

  • The chess pieces and the iron throne model were downloaded from the Blendswap website
  • The HDRI environment maps were download from the website hdrlabs.com
  • The motivational pictures were taken from Flikr.
  • Thanks to Wenzel Jakob and Bennedikt Bitterli for their open source renderers (Mitsuba and Tungsten) which proved a valuable source of reference for certain implementations.