Illuminating Raven: Adding HDR and Advanced Lighting to Raven

Hi everyone and welcome to the fifth blog of my ray tracing journey. In this assignment, I have implemented new types of lights in Raven; directional, spot and environment light. In addition to that, Raven now supports High Dynamic Range (HDR) rendering and tone mapping.

Dragon New with Spot Scene rendered in 287ms

Implementation:

  • HDR Rendering and Tone Mapping

We will no longer save our outputs as PPM or PNG files that clipped to 8-bit [0-255] range. Instead, we can save the rendered images as HDR format using the .exr format. Additionally, Raven will have the capability to tone map these images and save them as PNG images. For reading and writing HDR images, I used tinyexr library. For tone mapping, I implemented Reinhard’s Photographic Tonemapping Algorithm.

Cube Point HDR Scene rendered in 39ms.

  • Directional Light

Directional lights are defined by two key parameters, radiance and direction, and are treated as if they originate at an infinite distance, making all rays parallel. This setup is ideal for simulating sunlight in a scene, as the light consistently arrives from a single direction. 


Cube Directional Scene rendered in 33ms

  • Spot Lights

As opposed to point or area lights that illuminate in all directions, spotlights focus their illumination within a specified angular range. They are defined by three parameters: Direction, CoverageAngle, and FalloffAngle. Inside the FalloffAngle, the light shines at full intensity. In the region between the FalloffAngle and the CoverageAngle, the radiance decreases according to a Falloff Factor based on those angles. Beyond the CoverageAngle, no light is emitted at all.

Dragon Spot Light Scene with 900 samples rendered in 63.9sec

  • Environment Lights

Environment lights are different from other types of lighting because they are defined by a (HDR) image. To check for shadows, a direction vector is sampled from the upper hemisphere using uniform random rejection sampling, under the assumption that the scene is enclosed within a sphere. This direction is then translated into (u, v) texture coordinates, which are used to retrieve the corresponding color value from the environment map. There are many projection methods to sample the environment map such as Lat Long and Probe methods. In this assignment, these two methods can be used.


Empty Environment Light LatLong Scene rendered in 66ms


Empty Environment Light Probe Scene rendered in 68ms


Sphere Point HDR Texture Scene rendered in 261ms

Sphere Env Light Scene with 900 samples rendered in 13sec

Mirror Sphere Env Scene with 900 samples rendered in 1.8sec

Glass Sphere Env Scene with 900 samples rendered in 1.5sec

Issues

I realized that I was incorrectly calculating Debevec’s equirectangular environment maps. Instead of dividing by π, I mistakenly divided by 2π.

When calculating radiance in Environment Lighting, I mistakenly used the hitpoint’s normal instead of the incoming light direction (Wi). Replacing the hitpoint’s normal with Wi resolved this issue.





There was a problem in my no-hit logic. Instead of returning color from Environment Map, I returned BackgroundColor. 

Some Notes:
  • I still haven’t resolved my smooth shading logic, despite spending nearly six days on it. As a result, I couldn’t give my HW5 assignment the attention it deserved, my apologies! Once I fix the issue, I plan to create new scenes.

  • I couldn’t fully complete HW5 on time because I spent days trying to fix smooth shading issue and a problem with the mirror and glass sphere scenes. As a result, I submitted the assignment without rendering support for those scenes. Two days later, I discovered the problem and fixed it, but I decided not to revise my submission. However, as shown above, I can now successfully render these scenes.



Comments

Popular posts from this blog

Leveling Up Raven: BVH, Transformations, and Instancing

Raven: The Beginning of My Ray Tracing Journey

Enhancing Raven: Multisampling and Distribution Ray Tracing