I wish we could have just one of these tutorials properly cover the concern of triangle clipping. This is the part that I struggle with the most in a software renderer. If you are going to be building a practical one, this is something you will eventually have to deal with, even for super basic scenes. Any time geometry intersects the view frustum you need to clip those triangles.
I went through this a few months ago in Rust. I wrote all the code by hand, no LLMs. Then I went ahead and added a small "game" on top, plus some special effects like pixelization shaders and chromatic aberration at the edge of a flashlight.
if anyone is interested! The repo has lots and lots of in-progress screenshots so you can see the renderer come to life, plus all the hilarious visual bugs along the way.
I learned a lot! My biggest lesson, other than the specifics of how rendering works, was that modern CPUs are really fast: a single-threaded CPU renderer can definitely run an interactive 3D game with some fancy special effects.
This resource, along with Mathematics for Computer Graphics by John Vince [1], was truly indispensable when I wrote my own software renderer [2]. This was long before LLMs, so the whole process took me at least a couple months - most of it trying to wrap my head around math behind computer graphics and tracking down C segmentation faults. Fun times.
There was a software rendered game in vein of Tomb Raider 1 graphics for both DOS and Unix, but I can't remember its name. It was an exploration game, modern, a bit cyberpunkish, in 3D.
Hey! Gustavo here. Thanks for the mention. The 3D software renderer course is still one of my favorites, even though it was one of the first ones I've published. I recently re-recorded the chapter on perspective projection matrix.
Is the Foley/Van Dam book still a go to resource for this? It seems it was updated in 2013, but, honestly, I’m more familiar with the ‘82 edition that was dedicated to 2D.
Back in the day, it was The Book for computer graphics.
I haven't looked at my copy in years. To me, the book is a peculiar encyclopedia with some historical importance.
I found the course note from this github to be a good refresher on the subject. While the repo source code style is distasteful to me and their old-school rasteriser in the course is too naive and unoptimal, it's still a better read than Foley I'd assume :)
In a fit of 90s nostalgia I’ve also been going back to software rendering, though I’m doing a hybrid of 2D style CLUT banks with a more modern binned triangle and barycentric technique. Since I’m sticking to a fixed pipeline look, I’ve been amazed at just how many triangles one can push even with a fairly naive draw function.
There's basically no such thing as "bare C++" anymore. On any modern machine you are relying on piles of code. You can't just write to registers to edit vram and output video like on some 80s computer. It all happens on top of a thick stack of APIs, drivers and firmware.
That's impressive. Building a renderer from scratch sounds like one of those projects that teaches you far more than following tutorials ever could. I'll definitely check out the screenshots.
24 comments
[ 1.2 ms ] story [ 29.7 ms ] threadhttps://github.com/kshitijl/tinyrenderer-rs
if anyone is interested! The repo has lots and lots of in-progress screenshots so you can see the renderer come to life, plus all the hilarious visual bugs along the way.
I learned a lot! My biggest lesson, other than the specifics of how rendering works, was that modern CPUs are really fast: a single-threaded CPU renderer can definitely run an interactive 3D game with some fancy special effects.
An error occurred: API rate limit already exceeded "
[1]: https://www.amazon.co.uk/Mathematics-Computer-Graphics-John-...
[2]: https://github.com/nkanaev/tipsy
Back in the day, it was The Book for computer graphics.
The languages have evolved across editions, from Pascal, to C, to C and C++, and a bit of C# as well on the last one.
Naturally it misses on several new concepts, however I would assert it has quite valuable content.
I found the course note from this github to be a good refresher on the subject. While the repo source code style is distasteful to me and their old-school rasteriser in the course is too naive and unoptimal, it's still a better read than Foley I'd assume :)