GPSnoopy / RayTracingTheNextWeek

Implementation of Peter Shirley's Ray Tracing The Next Week book.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ray Tracing The Next Week

My take on Peter Shirley's Ray Tracing The Next Week book. This is the second book in his Ray Tracing In One Weekend series. My take on his first book is available here.

On top of my own programming style, I have added:

  • Multi-threading support.
  • Optimizing AABB ray intersection by removing conditional branches (this runs faster on any modern processor).
  • Building the BVH tree using depth%3 splitting rather than random one (this seems to run faster in my case).
  • Using SSE and AVX instructions for implementing the Vec3 class.

The Earth texture was found on NASA's The Blue Marbe.

Building

Visual Studio 2019 project files provided as-is. Use build_linux.sh for a GCC build, be sure to change the -march=skylake to match your processor.

Performance

The cover picture was rendered in about 26h running 14 threads on a Core i9-9900K @ 4.7GHz at 3840x2160 with 65536 samples per pixel. I've used GIMP to open the resulting PPM image and convert it to more standard formats such as PNG and JPEG.

For best performance, I recommend the Linux build even on Windows (I've used Ubuntu 18.04 running via WSL on Windows 10 1809). For some reason, GCC (7.3) seems better at generating AVX FMA instructions than Visual Studio 2019 (16.3) on this code.

About

Implementation of Peter Shirley's Ray Tracing The Next Week book.


Languages

Language:C++ 98.5%Language:C 1.4%Language:Shell 0.2%