r/GraphicsProgramming • u/yetmania • Sep 07 '25
CPU Software Rasterization Experiment in C++
Inspired by Tsoding's post about Software Rasterization on the CPU, I gave it a try in C++. Here are the results. The experiment includes depth testing, back-face culling, blending, MSAA, trilinear filtering, gamma correction and per-pixel lighting.
I am impressed that a CPU can draw 3206 triangles at 1280x720 with 4x MSAA at ~20FPS. I wouldn't try to build a game with this renderer, but it was a fun experiment.
216
Upvotes
2
u/fgennari Sep 07 '25
It sounds like you need a depth prepass. Or you can sort triangles from front to back and use the depth buffer. I haven't actually written a software rasterizer, but it seems like the same tricks would apply to reducing overdraw.