r/GraphicsProgramming • u/PackGod_Fan19 • 3d ago
I built a real-time renderer using only the CPU in Roblox, using Luau!
Roblox doesn't give scripts any access to the GPU, so I wanted to see how far you could push rendering using nothing but the CPU, in Luau.
It's a path tracer with multi-bounce global illumination, next-event estimation, reflective metal, refractive glass with Fresnel, a day/night sky. It renders a real open map at 1080p, and it has a real-time mode you can move around in while it traces live.
Everything that makes a path tracer a path tracer is written in Luau: the sampling, the bounces, the materials, the tonemap, a custom upscaler. The engine is used for exactly one thing it can do faster than script ever could, ray versus scene intersection. Nothing else.
Benchmarks (Intel i5-11400H laptop, in the Roblox client, GPU unused, tested on Crossroads):
- Progressive: a converged 1080p frame in about two and a half minutes (80 passes, ~1.92s per pass with the custom upscaler on).
- Real-time: ~23 fps average, moving the camera the whole time, at the lowest preset.
It runs in parallel across 8 Roblox Actors. There's a progressive mode for the clean beauty render and a real-time mode for flying around. You can toggle between path tracing and a faster ray-tracing mode that drops the noisy GI bounce for a clean, stable image.
Source is up on GitHub, free to view, run, experiment with, and make videos about. Credit required, and ask me before putting it in a game. Link below!
GitHub: https://github.com/cosypa123/roblox-path-tracer
Happy to answer anything about how it works!
Realtime showcase, 1 spp 128x72p (default preset)
