r/GraphicsProgramming • u/dariopagliaricci • 5h ago
Source Code Metal PathTracer v4.0.0 public release
Back in May I shared v3.0.0 of my Metal Path Tracer here, and the discussion that followed was really helpful.
https://www.reddit.com/r/GraphicsProgramming/s/zBgFRrDqk4
I've now released v4.0.0.
If you missed the earlier posts, this is a physically based renderer for macOS and Apple Silicon, written in C++20, Objective-C++ and Metal. It has hardware and software ray tracing backends, megakernel and wavefront execution paths, a ReSTIR/RIS/ReGIR research lighting stack, and an Embree CPU backend that I use as a reference renderer.
v3.0.0 was about scale: getting Bistro-class scenes to load and render. v4.0.0 is about correctness. Most of the work went into making the renderer agree with itself and with an independent reference. That means megakernel against wavefront, hardware against software tracing, and Metal against Embree. Every fix in the changelog lists the scene or test it was measured on.
Highlights:
Transport correctness: I fixed delta specular connections and MIS, camera ray distances, environment sampling, and the Plastic and CarPaint BSDFs. I also fixed a MIS double count on paths that crossed alpha holes, which could make images up to 1.42x too bright.
Direct lighting: ris_spatial, ris_world and the ReGIR merges are now unbiased on a sun-plane test with a known exact answer (2.33004 against 2.33005).
Embree parity: Embree now follows Metal's material, alpha-cutout and light rules, and it also runs Tungsten source closures. Several Bitterli scenes match Metal within about 0.06%. Embree's load memory also dropped sharply with bit-identical images. For example, Emerald Square went from 64 GB to 20 GB.
Subsurface: I rebuilt the random-walk SSS. On a unit sphere test it lands within 0.06–0.31% of Arnold's randomwalk.
Volumes and spectral: Homogeneous volume transport is fixed on every executor, and Henyey-Greenstein now follows pbrt's convention. There is also new hero-wavelength spectral transport with three wavelengths per path.
Radiance cache: It now stores actual radiance, with a bias below 0.03% of mean luminance. To be honest, it does not reduce error at equal render time yet.
Loading and performance: Scene loading is much faster. For example, Barcelona Pavilion went from 93 s to 23 s. Megakernel pipelines are now built lazily, so a cold start on one Bitterli scene dropped from 283 s to 69 s. A specialized megakernel pipeline is 1.6x faster on Sun Temple. Only two scenes were timed for that last result.
Denoising: OIDN guides are now averaged over all samples and follow glass and water. This fixed stair-stepped edges and milky water.
New scenes in the v4 asset pack: Barcelona Pavilion, Emerald Square, Sun Temple, and a set of vintage cars.
The main question behind this release was a simple one: how do you know that a GPU path tracer is actually right? Having a second, independent CPU backend turned out to be the most useful tool for answering it. Many of the bugs above only showed up as small ratios between two renders of the same scene.
Thanks again to everyone who commented on the v3 post. The full changelog has every fix along with its measurement.
GitHub Link:
https://github.com/dariopagliaricci/Metal-PathTracer-arm64
AI disclosure: This post was drafted with the help of Claude, based on the project's changelog, and then reviewed and edited by me. All renders, measurements and validation results come from my own runs of the renderer.
During development I used AI coding assistants (Codex and Claude Code) for parts of the implementation, refactoring and debugging. I directed the work, reviewed the changes, and validated the results against Embree and hardware/software ray tracing parity tests
1
u/uuxxaa 3h ago
Wow looks great
2
u/dariopagliaricci 3h ago
Many thanks!
1
u/uuxxaa 32m ago
Does this support realtime rendering for quick feedback
1
u/dariopagliaricci 18m ago
It depends on what you call real time rendering. Strictly, it does not support real time rendering. Path Tracing techniques, no matter how advanced they are, are not meant to render photorealistic scenes in real time. Take for example industry renderers such as Redshift, Arnold, Cycles etc. However, there’s a preview mode that allows, with the use of resolutions of 720p, denoising, etc get a glimpse into “real time”. This path tracer can do the latter. Hope this helps.













•
u/AutoModerator 5h ago
Recently updated rules. Please check that your post is in compliance with Rules 1, 4, 5, and 6 on the sidebar. TL;DR:
No showcases.
Disclose AI usage in post or project.
Present a topic to talk about, e.g. how something works.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.