A game that draws itself in ASCII
A C++ game made during a folkehøyskole game-jam, with a CUDA-accelerated ASCII shader sitting between the renderer and the screen. The shader picked the best glyph for every pixel patch in real time, and the same kernel could read your webcam and turn your face into typography.
The idea
A "code zone" inside the game switched the renderer into ASCII mode. Not the usual brightness-bucket trick, but a per-patch best-match against a small glyph atlas, running on the GPU so it stayed at frame-rate.
How the shader works
- The framebuffer is tiled into character-cell sized patches.
- Each glyph in the atlas is pre-rendered into a tensor at the same size.
- For each patch, the kernel scores every glyph by structural similarity and picks the best match.
- If a patch is, say, white only on the bottom edge, it lands on
_, because that's the glyph whose mass distribution matches.
The trick was making this cheap enough to run per-frame. CUDA, per-block scoring, and a small atlas got it well under a millisecond at 1080p.
Webcam mode
The kernel is content-agnostic, so feeding it a webcam frame instead of the framebuffer just works. Live ASCII selfie:
Live ASCII webcam, running on the same kernel.
What I'd revisit
The matching is purely structural. It doesn't know that O and
0 look almost the same. Adding a small perceptual term, or running the
score against an edge map, would clean up the typography. And the atlas was
monospace-only; with a proportional font and a smarter packer there's more visual
variety to be had.