Hey HN, 5 years ago I was 17 and learning to code C/C++ in a coding bootcamp (42). One of the projects was a simple C ray tracer. I really enjoyed working on the project and always loved computer graphics, so I decided to create my own path tracer from scratch, in C++, without using any third-party libraries. I ended up working on it consistently for over a year, then sporadically when CG excitement hit me again. Rec…
> Btw this was initially coded without AI, but I've used it for the recent clean up and features Then it makes sense to update the submission title. To me it reads as if the project was written completely without the help of AI (which might be a quality badge to some), but it is not 100% true then. Anyhow, cool project ;)
Show HN: I wrote a C++ ray tracer from scratch without AI
21–30 of 67 posts
Re: Show HN: I wrote a C++ ray tracer from scratch without AI
#22???
Re: Show HN: I wrote a C++ ray tracer from scratch without AI
#23Earlier quoted context omitted.
> Btw this was initially coded without AI, but I've used it for the recent clean up and features Then it makes sense to update the submission title. To me it reads as if the project was written completely without the help of AI (which might be a quality badge to some), but it is not 100% true then. Anyhow, cool project ;)
Thanks! I get your point about AI, but I think it's fair to say it's almost 100% AI free. I worked on it for ~15 months, vs 1 week now with AI. Previous results were quite similar
So write "almost without AI" in the title, then!
Re: Show HN: I wrote a C++ ray tracer from scratch without AI
#24> without AI Now this is how you catch attention
Re: Show HN: I wrote a C++ ray tracer from scratch without AI
#25Re: Show HN: I wrote a C++ ray tracer from scratch without AI
#26Very fun! Packing data for GPU-side BVH was quite tricky.
Re: Show HN: I wrote a C++ ray tracer from scratch without AI
#27Re: Show HN: I wrote a C++ ray tracer from scratch without AI
#28Me too, but in TS/WebGPU: https://github.com/ivanjermakov/moonlight Very fun! Packing data for GPU-side BVH was quite tricky.
Re: Show HN: I wrote a C++ ray tracer from scratch without AI
#29Have you considered rewriting it in Rust? Not for any technical reason (I say it reflexively now)
Re: Show HN: I wrote a C++ ray tracer from scratch without AI
#30Hey HN, 5 years ago I was 17 and learning to code C/C++ in a coding bootcamp (42). One of the projects was a simple C ray tracer. I really enjoyed working on the project and always loved computer graphics, so I decided to create my own path tracer from scratch, in C++, without using any third-party libraries. I ended up working on it consistently for over a year, then sporadically when CG excitement hit me again. Rec…
JFYI: Your inverse ray direction calculation is not NaN-safe: if rays are completely axis-parallel in one dimension, so the direction value is 0.0 for that axis, you'll be doing the val / 0.0 which results in a NaN... Also, as you're using full double/f64-precision all the time, you're leaving a fair bit of performance on the table: transcendentals (sin(), cos(), etc) in particular - can be a lot slower than when usi…
There's another issue that popped up on my quick naive profiling run: std::shared_ptr in the HitRecord/HittableLightSample is assigned/copied and destroyed a lot, and somehow these refcount operations show up as half of all samples on my profile (presumably because even if there's no hit and the pointer stays nullptr, the smart pointer still must check if there's anything to deallocate).