Software rasterizer · Rust
Prism is a 3D rendering pipeline written from scratch in Rust. No GPU, no graphics crates. Just a framebuffer, a z-buffer, and barycentric math turning vertices into pixels.
cargo run -- render -o out.ppm
drag to orbit · rasterized on the CPU, per pixel
Each triangle walks the bounding box of its three screen-space vertices. For every pixel center, three edge functions decide whether the point lies inside; their signed ratios are the barycentric weights.
Those same weights interpolate depth across the face, so every covered pixel arrives at the depth test with a z of its own.
let l0 = w0 / area;
let l1 = w1 / area;
let l2 = w2 / area;
let z = l0 * v0.z
+ l1 * v1.z
+ l2 * v2.z;
fb.set_with_depth(x, y, z, color);
One depth value per pixel, holding the nearest surface drawn so far. A fragment writes color only if it is closer, so triangles behind others are hidden regardless of the order they were submitted in.