I built a real-time 3D LEGO Raymarcher in the terminal (~70 FPS, zero Python/C). Then I squeezed the entire project down to just 11 KB.
Hey everyone!
I’ve been experimenting with low-level software rendering inside standard Linux terminals. I wanted to see how fast I could march 3D Signed Distance Fields (SDF) and render dynamic, illuminated 3D geometry without using any heavy frameworks, Python wrappers, or C/C++ source files in the project.
The engine renders an animated 3D LEGO® Minifigure (walking animation, waving arm, facial details, space emblem) and a Space Rover on a studded baseplate at 160x48 resolution @ ~70 FPS with 24-bit ANSI TrueColor, PBR clearcoat gloss, soft shadows, ambient occlusion, and interactive WSAD camera flight.
After getting it running smoothly, I decided to see how far I could push the footprint optimization without losing a single frame or feature.
📏 File Footprint Breakdown (200 KB →→ 11 KB Total)
Here is how the project breaks down before and after stripping/compression:
textSOURCE CODE (DSL):
• scene_lego.hray : 2.4 KB --> 0.9 KB (Minified DSL scene description)
• hray_compiler.hydra : 2.7 KB --> 1.1 KB (VLIW-8 Hardware Microcode)
• hray_compiler.hmat3d : 2.8 KB --> 1.0 KB (3D Spatial Matrix Definitions)
--------------------------------------------------------------------------
Total Source Code Size : 9.2 KB --> ~3.0 KB (Full 3D Scene + Microcode)
COMPILED NATIVE BINARY:
• Raw Executable Binary : 27 KB --> 14 KB (Stripped debug symbols)
• UPX Compressed Binary : 14 KB --> ~7 KB (Self-extracting ELF executable)
COMPLETE REPOSITORY FOOTPRINT:
• Initial workspace size : ~200 KB (including benchmark builds)
• Minified total size : ~11 KB (Over 94% total footprint reduction!)
🛠️ Key Technical Highlights:
- Custom Vector Language (DSL): Everything is defined in
.hray(geometry/materials),.hydra(instruction stream), and.hmat3d(spatial transformations). - SIMD Alignment: Ray packets execute in 8-lane AVX2/FMA3 SIMD vector passes directly on CPU registers.
- Artifact-Free Precision: Fixed surface penetration gradient collapse (black spots) by enforcing 1.0x conservative stepping precision and camera-vector fallback normals.
- Zero Overhead: Launches instantly from terminal via a 1.5 KB shell script.
The entire project — source code, microcode, shaders, materials, and executable binary — fits into ~11 KB, which could easily fit on a vintage 5.25" floppy disk with 99% of space to spare.
Happy to answer any questions about the SDF mathematics, SIMD vector alignment, or terminal framebuffer commit optimizations!
Subreddits & Tags
#programming #graphicssoftware #gamedev #CommandLine #linux #LowLevel #SIMD #AVX2 #Raymarching #Lego