Project Info

Bidirectional Path Tracing

Computer Graphics
PBR
  • Date:
    2024 June
  • Location:
    Pittsburgh, PA
  • Team:
    Daaa Zhao
  • Instructor:
    Ioannis (Yannis) Gkioulekas
  • Role:
    Programmer

Bidirectional Path Tracing

Bidirectional Path Tracing

Regular path tracing struggles with “hidden” light sources located behind corners, walls, or ceilings because rays emitted from the camera are unlikely to reach these sources within a limited number of samples and bounces.

Bidirectional Path Tracing (BDPT) addresses this issue by combining forward and backward path tracing. While traditional path tracing traces rays from the camera to the scene, BDPT also traces rays from light sources into the scene. This approach creates paths that connect light sources to the camera through multiple bounces and interactions with surfaces.

By integrating these paths, BDPT enhances the simulation of complex lighting effects such as caustics, indirect lighting, and glossy reflections, resulting in more accurate and visually appealing images compared to standard path tracing techniques.

1. Motivation for Implementing BDPT

As the figure shows, a light source illuminates only a small area on the ceiling, and the rest of the room is lit only by indirect light bounced from the ceiling. In this case, a traditional path tracer will find it challenging to successfully find a path to the light source. Most paths will contribute nothing to the final image and will be a performance waste.

However, in the theory land, if we construct two light paths, one starts from the camera, the other starts from the light source, and then connect the two paths in between, we would handle this situation more effectively. This technique is called Bidirectional Path Tracing.

For implementation, we will utilize the Dartmouth Introductory Ray Tracer as our code base. It would be a good starting point to start playing around with graphics concepts.

Figure: Difficult path in the traditional path tracer.

2. Methodology: Single Scatter

Implementing the BDPT into an existing code base could be risky and hard to debug. So, we initially start by restricting ourselves to a full path with only one bounce on the camera side and one bounce on the light side.

To start with, in order to test the whole procedure, we built a simplified version of the scene without blocking the light source. In this scene, we will only allow our eyeRay and lightRay to each have only one intersection with the scene. Then, we connect the intersection points of both ends. After that, we calculate the throughput of the whole path and get the final result, which should be relatively straightforward.

This will be a more "hard code" style version, but we think it would be a good starting point to keep all the behaviors more predictable.

Figure: Single Scatter BDPT with simplified scene.

3. Methodology: Simple BDPT without Shadow Rays

After the previous steps, we would have a single scatter version of BDPT working. Now, we add variations to our code base to allow the rays to scatter multiple times in our scene.

After doing so, our path tracer will already gain the ability to allow rays to “escape“ from behind corners, which would be a significant improvement over the traditional path tracer.

Once again, we keep it relatively simple by not counting all the shadow rays between two paths and only considering the direct connection between two ends. This end-to-end version could help us focus on both directions' recursive hits and observe the difference between this and the single scatter version.

Figure: Multiple Scatter BDPT, end-to-end connection.

4. Methodology: Full BDPT with Shadow Rays

To improve BDPT's efficiency and accuracy, we can introduce the concept of shadow rays. Shadow rays are additional rays cast between the eye path nodes and the light path nodes to determine their visibility. By connecting these nodes with shadow rays, we can explicitly check if any occluders are blocking the light transport between them.

With the previous end-to-end version, we can now consider each node in the path as a new end, and connect it to other ends. After all, shadow rays are just more end-to-end connections.

As the figure shows, the shadow rays shoot from every node in the eyePath to every node in the lightPath. Unlike the previous solution, which only had one connection between the ends of both paths, this new method does not waste the whole path when some connections are blocked.

Figure: Full BDPT utilizing shadow rays.

5. Result: Simple BDPT without Shadow Rays

At this point, the ray is already tracing "bidirectionally." So, let's take a typical scene that BDPT can most likely handle well and compare the results to some traditional solutions to see the differences.

For instance, in rendering a scene illuminated solely by indirect light from a hidden light source, BDPT, even without shadow rays, clearly outperforms traditional Path Tracing and Direct Next Event Estimation (NEE). It enhances performance in such scenarios, highlighting its ability to handle complex lighting interactions that traditional methods struggle with effectively.

However, when compared to Path Tracing with Multiple Importance Sampling (MIS), our current BDPT results exhibit more noise, particularly high-frequency noise. This type of noise is challenging to mitigate during the post-rendering stage and can significantly affect the overall quality of the rendered image.

Figure: Comparison of BDPT without Shadow Rays, v.s. Path Tracing, Direct NEE, and Path Tracing MIS

6. Result: Full BDPT with Shadow Rays

Now, when we connect the shadow rays between every node in the eyePath and every node in the lightPath and calculate their total contribution, we observe a significant improvement. The results are much better, and in some areas, it even outperforms Path Tracing with Multiple Importance Sampling (MIS).

Incorporating shadow rays into BDPT captures more accurate lighting information, effectively handling complex occlusion and indirect illumination. Shadow rays determine visibility between the eye path and light path nodes, ensuring only unoccluded connections contribute to the final image.

Without shadow rays, noise occurs because the algorithm can't accurately determine visibility between nodes, leading to incorrect lighting calculations. Shadow rays solve this by validating connections between paths, reducing the likelihood of incorrect lighting contributions, and improving overall render quality. By incorporating shadow rays, BDPT not only handles complex lighting better but also reduces noise, resulting in cleaner, more accurate renders.

Figures: BDPT without/with shadow rays: noise details.

7. Exploration: Playing around with Path Lengths

Playing around with eyePathLength and lightPathLength is important in BDPT because these parameters control the trade-off between rendering quality and computational efficiency. Adjusting these lengths affects the following aspects:

  • Path Complexity: Increasing the path lengths generally allows more complex light interactions, such as multiple bounces, caustics, etc.
  • Noise Reduction: Longer paths generally lead to lower noise levels in the rendered image.
  • Computational Cost: Increasing the path length will dramatically increase the computational cost, and may outweigh the improvement in image quality.

When the light path length is short, it performs poorly because it does not give the light enough chance to "escape" from a hidden place. On the other hand, when the path length increases from 2-3 to 2-4 or 3-3, the results do not differ much, while the rendering time is almost twice as long. So, we know this particular scene has reached an edge where the additional computational cost may outweigh the quality improvement.

Figure: BDPT with different eyePathLength and lightPathLength

Read Me

Daaa Zhao

Daaa is a junior developer specializing in game dev, computer graphics, and machine learning. He is currently involved in projects integrating ML into games and graphics, aiming to push the boundaries of interactive experiences. With a solid foundation in programming and hands-on experience in Unity, Daaa is eager to expand his skills and contribute to innovative projects. His passion for learning combined with his growing expertise in ML, makes him a promising talent in the evolving landscape of digital media and immersive technologies.

Project Coords

Interdisciplinary is precisely what I am good at. Every time the inspiration burst, in order to set the idea free from limits, I would learn some new skills to counter the challenge. Over time, I have broadened my skillset widely open, from art to tech, from reality to virtuality. Below is an axis graph to explain the Art-Tech/Digital-Physical coordinate of the skillsets used in my projects.

Special Thanks

Thanks to Matthew P Munger who created and shared this open source MattOS. This is really a powerful and enjoyable tool to use. I also learned a lot from how he manages this front-end system. Welcome to check out and support his work!

Gallery
The Form Generation of an Organically Shaped Pavilion
What if you run out of some ingredients when making a dish?

Sure, you can go out to purchase some. But also, you can choose to revise the recipe a little bit based on the foods in your hand; and please be proud of it, that's human intelligence. However, we are losing this intelligence after industrialization. Is it appropriate to cut every unique tree into the same board?

  • Installation Art
  • AI Generated
IDEAS AR
This is an AR treasure-hunting game.

There are secrets hidden in the IDEAS campus; could you find them? Scan the QR codes on any suspect surfaces, collect clues, and unlock your final reward!

  • AR
  • Interactive Exhibition
if (isMeaningful)
{
   MakeItMeaningful();
   MakeItFun();
}
else
{
   MakeItFun();
}
Time Travel Bandit
Unstable cracks are appearing.

It’s becoming easier for people to travel through time and space. Our character, Baaa, is a professional thief. Recently, he has started to make a living by traveling through time and space and stealing treasure.

  • Shader
  • Architecture
Sonarogue
Eyes covered. How to survive the dungeon? Use sonar!

This game is made solo in a two-week game dev challenge. It's a sonar-detect roguelike game. In this dungeon, your vision is taken, and your only ability is to use a sonar device. Play it online on itch.io!

  • Atmospheric
  • Minimalistic
Daaa's Horse
Just squeeze.
  • Soft Body
  • Interactive
Don't Let the Cat Sleep
Get up, kitty!
  • Robot Arm
  • Pet's Toy
Chinese Calligraphy
This is a 40-meter-long calligraphy scroll.

It took me three months to create, and I treated every stroke meticulously. With such an opportunity, each stroke is an examination and tempering of my heart and spirit.

  • Calligraphy Art
  • XXXL Scale
Wander Corgi VR
Wanna be a dog and leave pee-mails to others?

In this VR experience, you will become a corgi, waking up and finding your favorite toy lost in the city. Be a detective! Read the pee-mails left by your friends, and discover the clues.

  • Animal View
  • VR
Modular Tile-based Generative Design
An architectural manifesto.

The future of democratic design and growing architecture with the participation of the GANs. Every opinion matters; how can we take them into design consideration with the help of AI?

  • Architectural Design
  • Graphic Design
Mask
The pandemic is the best time of my life.

The short film is a story about a woman worker being laid off by a mask factory before the pandemic. To pay for her salary, the factory gave her 1 ton of masks, which were worth nothing before the pandemic. But later, the situation changed. Mask has become a hot barter for money and sexual resources.

  • Set Design
  • Short Film
Daaa's HD
5 items
last modified 2023
created in 1998
Trash
4 items
Empty
Bad Emo
Broken Badminton
Broken String
Cat Poop
Trash
0 items
Empty

Maybe it's not a good idea to shut my website down without a hardware reset button. Proceed?

Just kidding. Nothing was actually shutdown. It wouldn't have been a good idea. Do it again?

Permission denied. Please reconsider your actions.