MiniRT — WebAssembly Ray Tracer
MiniRT — WebAssembly Ray Tracer
A real-time ray tracer running entirely in the browser via WebAssembly. Originally built as a 42 school project, MiniRT has been compiled to WASM to bring GPU-accelerated ray tracing to the web without any plugins.
Features
- Real-time Rendering — Interactive camera controls with smooth navigation
- Multiple Scene Support — Pre-bundled scenes including Billiards, Snowman, Solar System, and more
- Custom Scene Editor — Write and test your own
.rtscene files directly in the browser - File Upload — Load external scene files with full validation
- No Plugins — Pure WebAssembly, runs natively in any modern browser
Controls
| Input | Action |
|---|---|
W A S D | Move camera |
| Mouse | Look around |
R | Start high-quality render |
ESC | Exit interactive mode |
Try It Out
Launch the interactive demo: Open MiniRT
Technical Details
Architecture
The project consists of two main components:
- MiniRT Core — The original C ray tracer built with mlx_raylib (a minilibx/X11 compatible library)
- WebAssembly Build — Emscripten-compiled version running in the browser
Scene Format
MiniRT uses a simple text-based scene description format:
A <ratio> <R,G,B> # Ambient light
C <x,y,z> <dx,dy,dz> <fov> # Camera
L <x,y,z> <brightness> <R,G,B> # Point light
sp <x,y,z> <diameter> <R,G,B> # Sphere
pl <x,y,z> <nx,ny,nz> <R,G,B> # Plane
cy <x,y,z> <nx,ny,nz> <diameter> <height> <R,G,B> # Cylinder
Source Code
- Ray Tracer Core: github.com/zakaria-mourtaban/minirt42
- Graphics Library: github.com/zakaria-mourtaban/mlx_raylib