⚠️ Disclaimer: Per the judging criteria, this is a finished project in terms of path tracing. However, as stated in the video, this isn't a finished project in terms of a pull request to Godot.

Inspiration

I was inspired by this GodotCon talk by Leroy Sikkes. In this talk, an NVIDIA engineer who has brought pathtracing to many games - Cyberpunk 2077, Battlefield 1...- talks about his port to the open source game engine Godot. At this point the NVIDIA PR is still a work in progress. It's a breaking change that would require maybe a whole version bump of Godot + alot of compatibility work. To my knowledge, it's only working on Vulkan for now. As a diehard Apple Silicon and Godot fan, I wanted to have it working on my system. With the release of GPT 5.6 Sol, Terra, and Luna; I thought a Metal/Mac port might just be feasible..

What it does

How I built it

My strategy started with deep research. I got an agent to research with this prompt:

@Deep research there's a fork of godot by nvidia where they're adding raytracing to godot. https://github.com/NVIDIA-RTX/godot I would like to add compatibility to Mac via native metal. first, search the repo to see the state of Mac progress- if we want this merged to main it should be available for all platforms. then, give an abstract overview of what the porting process entails. then I'd like you to give me actionable chunks I can work on one by one via lllm's like 5.6 Sol and Fable- extremely powerful llms. these chunks should be small and verifiable. Finally, I need specific Apple guidance on Metal RT. Such as their Blender port.

I saved the generated document to a planning folder on the root of the repository. Then, I spun up a Codex agent to create a few tools that the agents might need in their pursuit: script with passes, byte by byte image comparisons, etc. Finally, I cloned Blender's source code in a folder on my desktop. I gave the path to it in the planning markdown file. This was very important because Apple themselves worked on the Blender path tracing implementation. They basically called it the example implementation. I find Ai agents work best when they can copy code, see examples, etc- just like humans! Then I let GPT 5.6 work on things chunk by chunk. Between each chunk I checked the results, found bugs, found crashes.

Challenges I ran into

In my pursuit I kept on running into these ugly artifacts in the render. Obviously, I didn’t want this. And I easily could make it go away. Wrapping the lighting code behind a function boundary killed the artifacts completely. But it also roughly doubled the path tracer's frame time (from ~5.8ms to ~11.3ms). After running for awhile GPT 5.6 Sol figured it out. It’s over my head so I’ll let it explain: “That's when I found the tell. Turning on Metal's shader validation made the corruption vanish — perfectly clean output, every time. Normally validation catches your bugs; here it was hiding one. Validation changes how the compiler assigns registers, and that was the whole ballgame. I dumped the raw GPU output before anything touched it and counted the bad pixels: ~450,000 corrupted with inlining on, ~120 with it off — same scene, same frame. The bad values were never garbage or infinity; they were always one color channel snapped to exactly zero, the rest correct. That's not a math error or a race. That's the compiler mis-tracking a value. I narrowed it down to a single ingredient: two ray-query traversals (one for the camera ray, one for shadows) living in the same kernel. Inline the shadow one and a scalar lane gets clobbered. Give it a real function call and its own local query object, and everything's correct — at full speed.” *So basically, GPT 5.6 found a bug in Apple's renderer. * I showed it my friend who knows alot about Metal and more low level things, and he agreed. So I submitted it to Apple.

Accomplishments that I'm proud of

It's still just astonishing to see ray tracing on my mac, in my own game scenes. I think that speaks for itself. Further, though, the idea that my orchestration might leave a fingerprint in Godot's src literally gives me chills ahah.

What I learned

One big thing I learned was that one should not ignore Terra and Luna. Terra is incredibly powerful, using it in Ultra mode barely costed me my Codex limit and was great for research across the repo. Luna was also great for computer use tasks.

What's next for Bringing Path Tracing to Godot Mac

I need to add intel Mac support and there are few more optimizations I want to add. Godot is very anti-Ai, which I entirely respect. Merging this branch is a huge "if". Nonetheless, while I wait for their implementation of path tracing, I'm happy to play with it on my own Mac and allow others to use and build on. A game I've been working on for awhile finally seems feasible and worth finishing. In the way I see it, ai/chatgpt enabled me to continue my creative works. It didn't destroy it, in fact- I came away from this with tons more ideas.

Built With

Share this project:

Updates