Skip to content

CPU 3D engine

A full pure-C# CPU 3D engine, rendered without a GPU

This is a complete game engine written in plain C# on the .NET base library alone - an archetype ECS, a software physics solver (gravity, raycasts, AABB and sphere contacts), and a from-scratch software rasterizer. No GPU, no game framework, no NuGet. The rasterizer builds primitive meshes, projects them through a perspective camera, and fills depth-buffered triangles with Pineda edge functions and directional shading - then hands back a raw uint[] framebuffer that becomes the images below.

ECS
archetype world
48
orbit frames
880×495
still resolution
0
GPU / NuGet
A cluster of lit 3D cube buildings of varying heights on a green ground plane, with a red landmark tower and a golden sphere, under a blue sky
Software rasterizer
One framebuffer

A procedural block city: two dozen lit cube meshes plus a sphere, each depth-buffered and shaded by a single directional light. Built with the engine's MeshBuilder, drawn by SoftwareRenderer.DrawMesh, read out as packed RGBA and encoded to PNG - all in-process.

An animated camera orbit around the 3D block city, the red landmark tower spinning at its centre
Perspective camera
Orbit flythrough

Forty-eight frames of a camera circling the scene, each one a full software render. The view and projection matrices, near-plane clipping and screen mapping are all hand-rolled - the same math a hardware pipeline hides.

What the engine is made of

An entity is an id; components live in archetype storage and are visited by typed queries. A software physics world integrates dynamic bodies under gravity, casts rays, and resolves AABB and sphere contacts with Baumgarte correction. The renderer turns triangles into pixels: it transforms each vertex to view space, clips against the near plane, projects to the screen, and rasterizes with perspective-correct depth and a directional sun term. Every part - the math, the ECS, the physics, the rasterizer, the PNG and GIF encoders - is C# on the base library, portable by transliteration and free of any external dependency.