r/GraphicsProgramming • u/Scared_Equipment5777 • Jul 15 '26
I spent a year building a software rasterizer learning resource in C from scratch.
Here is the github link if you want to poke around: https://github.com/Kristaq77/kross
I started learning to code about a year ago and decided to dive headfirst into C and computer graphics. At this point, Im pretty sure Im a masochist. There were times I felt like a genius and times I felt like the biggest idiot ever, often within the same hour.
Fast forward a year, and I finished my first big project: Kross, a software rasterizer built from scratch with a custom math "library", color manipulation, procedural noise, "and more".
A quick disclaimer: I did not build this for performance (mainly because I couldnt).
Instead, I made it as a learning resource. The code is meant to be read, not just compiled. I heavily commented the most important functions with explanations I desperately wanted to read when I was starting out.
Id love any feedback from the veterans here, whether its on the math, the "architecture", or the comments themselves :)
Full disclosure, no AI was used to create the library, but I did use AI to create one of the examples.
(The library also consists of a few stolen functions, which if you read the source code you will see who from).
3
u/Still_Explorer Jul 16 '26
This is the best software render ever written, and also heavily commented making it top learning resource.
If you turn this code into a series of blog posts, I am sure they will become very popular.
As I have tried to learn soft rendering a few times but it was infeasible. TinyRenderer omitted about 90% of all explanations, Pikuma is paywalled (and I have no problem paying - just what happens if the tutorial does not work for me?). Then there are hundreds of software renderers written on GitHub but require you to reverse engineer them and adapt to your learning style (which is not the best thing if someone is at the "I don't know what I don't know stage"
Honestly software rendering learning resources are cooked, your code is awesome. Well done.
2
u/forumonaut Jul 16 '26
Wow, this is seriously cool! How far have you pushed the optimizations?
For example, are you using tile-based rasterization to improve multithreading and cache locality?
You may have already seen my post, but I also built a software-rasterized voxel engine this year. It’s great to see other people exploring this area.
Let’s bring software rasterization back!
2
u/[deleted] Jul 16 '26
Hey, really nice!!!
2
u/Gabrunken Jul 17 '26
What the fuck.
That is impressive, but mostly surprising. How?
Is that true that you started learning how to code a year ago, and in the meantime you made this, in C as your first language? Do you have a degree in comp science? Just how man, how… Congrats, you deserve it.
1
u/darkriftx2 Jul 17 '26
This is a great project. Congratulations on learning C and computer graphics all at once. My journey with C started almost 30 years ago but took a similar path with DOS, Mode 13h, and other fun stuff. Look up some of Michael Abrash's work. The older versions of the Allegro library (v3 and below) are also treasure troves of cool graphics algorithms.
-3
u/Trader-One Jul 15 '26
custom rasterizers make sense only for small triangles which are used in movie rendering.
small triangle = area is about 1/3 of pixel.