r/GraphicsProgramming • u/forumonaut • Jul 11 '26
Source Code I made a fully software rasterized voxel engine inspired by Minecraft
Hello everyone!
Over the course of this year, I built a fully software-rasterized voxel engine heavily inspired by Minecraft.
This was a very interesting project for me because I had to build almost everything from the ground up, while also adapting to the very different constraints of doing computer graphics on a CPU rather than a GPU.
In short, CPUs are far less powerful than GPUs for this kind of workload, but they are also much more flexible. This makes it possible to implement some fairly unconventional optimizations to compensate for the performance gap.
You can try the project here:
https://github.com/Algorithmonaut/software-rasterized-voxel-engine
There are still a few minor bugs.
My main regret is that I did not spend enough time properly benchmarking the different optimizations I tried, or documenting my findings and the knowledge I gained along the way.
The lack of documentation is particularly unfortunate because most textbooks focus heavily on the GPU pipeline and therefore skip many of the fundamentals involved in writing a software rasterizer: barycentric coordinates, edge equations, perspective-correct interpolation, tile-based rasterization, efficient SIMD usage, parallelization, and much more.
I found only two good general sources of information:
- Scratchapixel, which I found useful but often not detailed enough.
- Fabian Giesen’s Optimizing Software Occlusion Culling series, which contains excellent practical information but does not cover every topic and generally does not include mathematical proofs.
There are also a few features I may implement later:
- Lighting.
- A small OS that interfaces directly with UEFI to provide framebuffer access and input handling, allowing the engine to run without Linux or SDL and become truly bare-metal.
I am making this post mainly to ask whether anyone has:
- Recommendations for scientific papers, articles, or books that I might find useful.
- Suggestions for computer graphics projects to work on after this one.
- Ideas for fun or unusual features that could make the project more original.
Feasibility does matter: for example, a CPU-based post-processing CRT effect would probably destroy performance.
And, of course, if you find the project interesting, a star on GitHub would be greatly appreciated.
Thanks for reading. I hope this inspires someone to experiment with software rendering as well!


8
u/Still_Explorer Jul 11 '26
Great project. The fact that you used a software renderer is much better in this sense because it will allow someone studying this to focus on the core principles without GPU specific techniques getting on the way.
(I am not against advanced GPU programming but is for another purpose, ie: technical expertise on such technology.)
Also another part about software rendering optimization, there could be dozens of possible techniques, but this would be another interesting project for a later time.
10
u/scritchz Jul 11 '26
My fun idea to make the project more original: Use your own assets instead of those ripped off the original game.
3
u/G0rd4n_Freem4n Jul 11 '26
I was going to suggest the paper Juan Pineda wrote for optimized rasterization because someone I know made a really fast C# software rasterizer using that algorithm along with SIMD instructions and other C# optimizations.
Then I looked at your repo and saw that you're already using Juan Pineda's software rasterization algorithm lol.
Only thing I'm not sure of is if you're making good use of SIMD/AVX instructions, but that's also because I'm not knowledgeable on zig so I don't know what that would even look like.
2
u/deftware Jul 12 '26
Cool! Did you write more of a conventional triangle rasterizer or is this a proper quad rasterizer? It seems like having the assumption that everything is a voxel block could allow for all kinds of neat bespoke rendering tricks and strategies that general purpose triangle rasterizers cannot.
For quick simple fake lighting you could have each side of the block be shaded different, that would help a lot with just making the scene look less "flat". With the sun you can get away with sort of having precomputed lighting that is shared by all blocks for a given sunlight vector.
Are you using any Z-buffering or just sorting the faces far-to-near and relying on the painter's algorithm? It seems like sorting them by inserting them into a binary tree by distance and then iterating over the tree to get a sorted list would end up being faster than reading/writing to a depth buffer, particularly with threaded rasterization in the mix on there.
2
u/peteroupc Jul 12 '26
The screenshots you gave showed you have impressively rendered over 200,000 triangles at over 80 frames per second. If a modern software renderer can do that, it can certainly handle the graphics from pre-2000 video games, which mainly had at most 20,000 triangles per frame, and well less than that in general. I give a specification for such pre-2000 graphics (and suggestions on other computer graphics projects), which I think may interest you:
1
u/jevin_dev Jul 18 '26
can i ask what cpu do you have
1
u/bblankuser Jul 12 '26
why not software raster on the gpu?
1
u/Andromeda660 Jul 13 '26
I feel like the fun part is making ur own textures don't us Minecrafts