Enhancing Raven: Multisampling and Distribution Ray Tracing

Introduction


Hi everyone, welcome to the third blog of my ray tracing journey. In this assignment, I have implemented several nice features in Raven, including multisampling, depth of field, area light, glossy reflection and motion blur. These new features enhance the realism of the rendered scenes, further expanding Raven’s power. 🐦

Deadmau5 Scene with 1 Area Light and 900 samples, rendered in 3min 55sec

Before you start reading my blogpost, I would like to introduce one of my favorite musicians “Deadmau5” 😊. I have rendered his icon in Raven. I want to share one of his songs that you can listen to while reading the blogpost. “Jaded” was released 17 years ago, and he recently remastered it, naming the new version as “Re_jaded”. I really love this version; it brings back memories of my childhood. Here’s link please listen to it. (Later, I might create this music video in Raven. I think the visualization is really cool.)

Implementation

Firstly, I implemented multisampling feature to Raven. Then, I added Area Light, DOF, Glossy reflection and lastly Motion Blur. I created a class for Area Light. I updated my Camera class according to the given new Camera features like aperture size and focus distance.

  • Multisampling

I implemented Jittered Sampling with Box Filtering for this part. To generate samples, I used the Mersenne Twister pseudo-random generator, generating values in the range [0, 1]. In future work, I plan to implement Gaussian filtering because some scenes has jagged edges, which I think Gaussian filtering can help to smooth out.

Cornellbox Scene with 100 samples, rendered in 4178ms

  • Area Light

Until now, Raven only supported Point Lights. To expand its capabilities, I implemented Area Lights in this assignment, it allows for the creation of soft shadow effects. Instead of a single fixed point for the light source, multiple points are randomly sampled across the area light, which produces naturally softer and more realistic shadows. (I am very excited that Raven now supports Area Lights. I really like to play with area lights to my scenes since it brings more realism to my scenes. 😊)

David Scene with 2 Area Light and 400 samples, rendered in 2min (btw I really like David's grayish version πŸ˜…)

David Scene with 2 Area Light and 400 samples, rendered in 2min

Cornellbox Recursive Scene with Area Light and 400 samples, rendered in 65sec

Cornellbox Scene with Area Light and 900 samples, rendered in 2min 34sec

  • Depth of Field
Raven only supported the Pinhole Camera model, which renders all objects in sharp focus. To create realistic camera effects like depth of field, new parameters are introduced like aperture size and focus distance. As a result, Raven can render objects with depth of field.

Spheres Depth of Field Scene with 900 samples, rendered in 8min 55sec
  • Glossy Reflection

To render metallic objects that are not polished, I implemented glossy reflections. This effect is achieved by randomly perturbing the reflection rays based on the material's properties.


Cornellbox brushed metal Scene with 400 samples, rendered in 25sec


Metal Glass Plates Glossy Scene with 36 samples, rendered in 17sec

  • Motion Blur

In real cameras, the shutter speed affects how motion is captured, causing moving objects to blur along their direction of movement. To simulate motion blur in Raven, I assigned each ray a random time parameter sampled between 0 and 1, where 0 represents the object's initial position and 1 represents its final position during the motion. (Note that time parameter is randomly generated only for the primary rays. All other rays, such as shadow, reflection, and refraction rays, use time parameters from their parent primary ray.)

Cornellbox Dynamic Scene with Motion Blur effect and 900 samples, rendered in 13min 52sec



Issues

Haha πŸ˜…, of couse I have faced many problems while implementing new assignment. I list and explain them briefly. Again I get fantastaic images. (istesem yapamam herhalde πŸ˜…)

  • Multisampling Issues: I implemeted filtering function incorrectly and these two images appeared. After fixing calculation problem in my filtering function, it was solved.


  • ONB Issue: I created ONB for glossy reflection incorrectly. After correcting ONB calculation, it was solved. (When I first saw this artifact, I thought Is UV mapping part of this assignment ?πŸ˜…)
  • Ply parser problem: Until now, we have been dealing with faces that consist of one triangle in PLY file format. However, Cornellbox Dynamic Scene has a mesh that its faces are formed with two triangle instead of one triangle. I need to parse PLY file to handle quad face parsing.


  • I faced a very embarrassing problem that took me two days to solve. The issue occured when I was trying to transform a MeshInstance. I found that I could successfully do this when “resetTransform=false ”. However, when “resetTransform=true”, I encountered difficulties. I created a debug function that transforms each triangle’s BBox and forgot to comment it. This debug function also transforms Base Mesh’s BBox which is not I wanted in this case. I commented my debug function and it was solved.πŸ˜•



Some Notes:
  • I did try to optimize my BBox intersection algorithm with the one I talked about in HW2 post, but I couldn't achieve a better result. I keep using my algorithm. My algorithm take 16ms seconds to render basic cornellbox scene. After using the other algorithm, it increased the rendering time to almost 10sec. (Optimization is my passion😁)
  • I did implement MΓΆller-Trumbore Triangle Intersection, but couldn’t achieve a drastic result. So, I leave my implementation as it is.
  • I didn’t have enough time to render video scene, I will do it in the next assignment.
  • I am waiting to implement vertex normals for rendering smooth models, as well as textures. Once these are in place, I'll be able to enhance my scenes even further.



Comments

Popular posts from this blog

Leveling Up Raven: BVH, Transformations, and Instancing

Raven: The Beginning of My Ray Tracing Journey