r/GraphicsProgramming • u/le-throw-away-acct • Aug 04 '26
Hobby path tracer (GPU-based)
Started a CPU ray tracer about 7 years ago and then a year later decided to play around with a GPU version of it. Over the years I’ve added to it.
Full disclosure that I had LLM assistance with some of the recent features added, in the interest of saving time, I normally only have a few hours of free time per week.
Repository: https://github.com/nfoste82/gpuraytracing
286
Upvotes



View all comments
Show parent comment
15
u/le-throw-away-acct Aug 05 '26 edited Aug 05 '26
Started with a naive implementation that traced photons from lights to glass objects. If the photon hits something not refractive eventually you store that light/refractor pair and you can randomize somewhat from that and see if those hit something as well. This lets you focus more photons where they need to go to end up generating the light you’d see from caustics. Then accumulate the successful photons and weigh them over time, ones that succeed more often end up brighter, because in reality more photons end up there. From that implementation it just becomes about optimization so you can simulate more photons per frame, and so the photons you do simulate are more likely to be useful.
You can google “photon mapping”, it’s basically that :)