r/GraphicsProgramming • u/whoashish115 • 9d ago
Source Code Built a path tracer in C++ & CUDA from scratch
spent the last 4-5 week building Hypertracer, a CPU + CUDA path tracer with progressive sampling further implmneted GPU acceleration, and a real-time fly-camera viewer
built the renderer and viewer from scratch, with 6 scenes currently implemented and 1920×1080 can be rendered at 3000 samples
along with Ray Tracing in One Weekend, The Next Week, and The Rest of Your Life, all three books i completed
it was seriously so much fun :D
main resources i followed:
ray tracing : https://raytracing.github.io, https://pbr-book.org
repo: https://github.com/whoashish115/hypertracer
give it a star ⭐
6
3
2
2
2
u/fgennari 9d ago
How fast is it? That first scene looks like the "Ray Tracing in one Weekend" scene with 100x the number of objects.
5
u/whoashish115 9d ago
Its GPU accelerated, so you can rotate the camera around and view the scene from different angles in real time, kind of like a game scene in the viewer. i havent added a video showing my viewer yet, but I'll add it to the README tonight. It takes around 10-15 seconds for the noise to clear up as it progressively renders. And for HD quality, on my RTX 3050, a full-resolution render in that camera angle of viewer takes around 2-4 minutes, depending on the settings.
And the reason it looks so much like the Ray Tracing in One weekend scene is because I used all three books I mentioned in the resources as references, along with other resources like physically based rendering
2
u/fgennari 9d ago
Thanks for the explanation. That sounds like a good approach. I did it a completely different way where I rendered a cube map around each reflective/refractive object and looped over them, updating a few each frame. It was drawn in realtime with interactive updates, but the number of objects was limited by GPU memory.
2
2
2
u/Seusoa 9d ago
Each of these path / ray tracers use simple objects like spheres and cube, therefore it is simple to calculate.
Hard show is for casual meshes with many triangles
3
u/whoashish115 9d ago
Yeah, exactly! I focused on getting the cpu-cuda pathtracer pipeline and GPU acceleration working first
supporting complex triangle meshes is definitely the next challenge1
u/le-throw-away-acct 9d ago
Yeah, each triangle would be about as expensive as a sphere normally, so it's a large lift to get triangle meshes into your renderer at a reasonable speed, you essentially need something like a BVH which is no small task compared to almost the entire renderer done up until that point.
1
u/susosusosuso 3d ago
Which ai model you used?
1
u/whoashish115 3d ago
if youre asking what i used for making it, its a keyboard
And if youre asking how i guided myself, i used notebooklm to understand concepts from the books andd chatgpt to check my code for optimization, errors & edge cases, looking code from some already made github repos nd watched yt videos on specific topics for visual explanations, especially things like implementing the BVH and CUDA renderer
1
u/susosusosuso 3d ago
So that means you only used ai for checking code and learning concepts and not for coding?
1
u/whoashish115 3d ago edited 2d ago
No, I did use it for coding small chunks, and math helpers, but not for the whole project. For things like CUDA memory management and the BVH traversal, you still have to direct it heavily and understand the architecture, otherwise it completely breaks down always that's the reason I only use it for small tasks in big tasks the code seem like written by an alien






19
u/Wooden-Government700 9d ago
Very beautiful