Skip to content

IsaGeriler/RayTracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RayTracer

An ongoing multithreaded offline ray tracer (CPU-based), written in C++, focusing on rendering, spatial acceleration structures, and multithreaded performance optimization.

(Note: This is an active Work in Progress. Current implementation covers high-performance spatial sorting and temporal rendering, with upcoming plans to integrate pure Monte Carlo integration and Probability Density Functions (PDFs).)

Current State

banner

Figure 1 - Evolution of the Ray Tracer.

RTMB

Figure 2 - Temporal Rendering (Motion Blur) integrated with BVH and hardware concurrency.

Performance Benchmarks: Algorithmic vs. Hardware Scaling

The following benchmarks were recorded rendering the high-density Book 1 final scene (approx. 500 primitives) to demonstrate the performance impact of algorithmic spatial sorting compared to raw hardware multithreading.

RTOWKNDFinal

Figure 3 - High-density benchmarking scene.

Benchmarks recorded on an Intel Core Ultra 7 155H, with VisualStudio 2022 being configured on Release mode with -O2 compiler optimisation. To maximize performance without being bottlenecked by hardware scheduling, thread count was dynamically set via std::thread::hardware_concurrency. For optimal results on this specific architecture, utilizing the 6 Performance (P) cores is recommended over the Efficiency (E) or Low-Power (LP) cores.)

Algorithm Sequential Multithreaded
Linear Intersection - $O(N)$ 3638.43 seconds (1 hour 38 seconds 430 milliseconds) 499.92 seconds (8 minutes 19 seconds 920 milliseconds)
BVH Traversal - $O(\log{N})$ 450.33 seconds (7 minutes 30 seconds 330 milliseconds) 84.64 seconds (1 minute 24 seconds 640 milliseconds)

Key Takeaways:

  1. Algorithmic Optimization > Hardware Brute Force: A sequential BVH implementation (~450s) actively outperformed a fully multithreaded brute-force approach (~500s).
  2. Hardware Scaling: After the $O(\log{N})$ spatial optimization, multithreading yielded a highly efficient ~5.3x performance speedup (~450s down to ~84s).
  3. Total Optimization: The combination of acceleration structure and hardware concurrency reduced the render time from over an hour to just 1.5 minutes, providing ~43x overall speedup.

Future Roadmap

  • Surface Area Heuristic (SAH) for optimized BVH node splitting.
  • Monte Carlo Integration and Importance Sampling.
  • Participating Media (Volumetrics/Fog).
  • Texture mapping and Perlin noise generation.

Citations

About

Implementing an offline, CPU-based Ray Tracer, by following "Ray Tracing in One Weekend/Next Week/Rest of Your Life" series, in preparation for WM9M3 - Advanced Computer Graphics (self-study).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages