Toy path tracer for my own learning purposes, using various approaches/techs. Somewhat based on Peter Shirley's Ray Tracing in One Weekend minibook (highly recommended!), and on Kevin Beason's smallpt.
I decided to write blog posts about things I discover as I do this, currently:
- Part 0: Intro
- Part 1: Initial C++ and walkthrough
- Part 2: Fix stupid performance issue
- Part 3: C#, Unity and Burst
- Part 4: Correctness fixes and Mitsuba
- Part 5: simple GPU version via Metal
- Part 6: simple GPU version via D3D11
- Part 7: initial C++ SIMD & SoA
- Part 8: SSE SIMD for HitSpheres
- Part 9: ryg optimizes my code
- Part 10: Update all implementations to match
- Part 11: Buffer-oriented approach on CPU
- Part 12: Buffer-oriented approach on GPU D3D11
- Part 13: GPU thread group data optimization
Right now: can only do spheres, no bounding volume hierachy of any sorts, a lot of stuff hardcoded.
Implementations I'm playing with (again, everything is in toy/learning/WIP state; likely suboptimal) are below. These are all on a scene with ~50 spheres and two light sources, measured in Mray/s.
- CPU. Testing on "PC" AMD ThreadRipper 1950X 3.4GHz (SMT disabled, 16c/16t) and "Mac" late 2013 MacBookPro 2.3GHz (4c/8t):
- C++ w/ some SSE SIMD: PC 187, Mac 41.8
- C++: PC 100, Mac 19.6
- C# (Unity with Burst compiler): PC 82, Mac 18.7. Note that this is super early version of Burst.
- C# (.NET Core): PC 53, Mac 13.1
- C# (Mono with optimized settings): Mac 12.7
- C# (Mono defaults): Mac 5.5
- GPU. Simple direct ports to compute shader:
- D3D11. GeForce GTX 1080 Ti: 1854
- Metal. Intel Iris Pro: 99
A lot of stuff in the implementation is totally suboptimal or using the tech in a "wrong" way. I know it's just a simple toy, ok :)
- C++ projects: Windows (Visual Studio 2017) in
Cpp/Windows/TestCpu.sln
, Mac (Xcode 9) inCpp/Mac/Test.xcodeproj
.- Windows is DX11 Win32 app that displays result as a fullscreen CPU-updated or GPU-rendered texture.
- Mac is a Metal app that displays result as a fullscreen CPU-updated or GPU-rendered texture.
- C# project in
Cs/TestCs.sln
. A command line app that renders some frames and dumps out final TGA screenshot at the end. - Unity project in
Unity
. I used 2018.1 beta 12 version linked to from ECS samples.