miniRT
High-performance raytracer in C · 2025
120+ FPS raytracer built on SIMD vectorization, cache-efficient data structures, and tile-based multi-threaded rendering.
- Frame rate
- 120+ fps
- Speed-up
- 80×
- SIMD
- SSE/AVX
Problem: I started building a basic raytracer in C to understand computer graphics fundamentals. The initial naive implementation achieved only 1–5 FPS when rendering complex scenes with multiple light sources.
Solution: I rebuilt the core rendering loop with C systems programming principles at its foundation. The approach combined SIMD vectorization using SSE/AVX intrinsics for batch vector operations, cache-efficient data structures using structure-of-arrays layouts instead of array-of-structures, and multi-threaded tile-based rendering to leverage multiple CPU cores.
Technical Approach: Three pillars: vectorization, memory hierarchy, parallelism. SSE intrinsics process 4 floats in parallel, AVX handles 8. I restructured data to exploit CPU cache locality by storing all X-coordinates contiguously, then Y, then Z. The renderer divides the framebuffer into tiles, with each thread processing one tile independently. Profiling with perf and cycle-accurate analysis revealed that the ray-primitive intersection test was the hottest code path.
Results & Learnings: The optimized raytracer renders at 120+ FPS — an 80× improvement over the baseline. Systems programming at the graphics layer isn't just about algorithms; it's about respecting CPU cache behavior, instruction pipelines, and memory bandwidth.
- Language
- C
- Concepts
- Linear algebra · optics simulation