A cross-platform 3D fractal viewer using ray marching, built with Rust.
- 6 Fractal Types: Mandelbulb, Menger Sponge, Julia 3D, Mandelbox, Sierpinski, Apollonian
- Real-time Ray Marching: GPU-accelerated signed distance field rendering
- Interactive UI: egui-based parameter tweaking with live preview
- Cross-Platform: Windows, macOS, Linux, Android, and WebAssembly
- Deep Zoom Support: Double-single precision emulation for zoom levels up to 10^12
- Switchable Lighting: Blinn-Phong and PBR (Cook-Torrance GGX) with interactive light direction control
| Action | Mouse | Touch |
|---|---|---|
| Orbit camera | Left click + drag | Single finger drag |
| Pan camera | Right click + drag | Two finger drag |
| Zoom | Scroll wheel | Pinch |
| Light direction | L + drag | - |
| Toggle UI | ESC | - |
| Reset camera | R | - |
| Auto-rotate | Space | - |
For a comprehensive feature reference, see the User Guide.
- Rust 1.75+ (install via rustup)
- For Android: Android NDK
- For Web: wasm-pack
# Debug build
cargo run -p fractal-app
# Release build (optimized)
cargo run -p fractal-app --releaseThe web build uses WebGPU for GPU-accelerated rendering. To run the live demo or build locally:
Browser Requirements:
- Chrome 113+ / Edge 113+ (WebGPU enabled by default)
- Firefox Nightly (enable
dom.webgpu.enabledin about:config) - Safari 18+ (macOS Sequoia / iOS 18)
# Install trunk for building
cargo install trunk
# Build and serve locally
cd crates/fractal-app
trunk serve --release --port 8080
# Open http://localhost:8080Alternative build with wasm-pack:
# Install wasm-pack if not already installed
cargo install wasm-pack
# Build for web
cd crates/fractal-app
wasm-pack build --target web
# Serve locally
python -m http.server 8080
# Open http://localhost:8080# Install cargo-ndk
cargo install cargo-ndk
# Build for Android
cargo ndk -t arm64-v8a -o app/src/main/jniLibs build -p fractal-app --releasefractal-viewer/
├── crates/
│ ├── fractal-core/ # Core math and fractal definitions
│ ├── fractal-renderer/ # wgpu rendering pipeline
│ ├── fractal-ui/ # egui UI components
│ └── fractal-app/ # Main application
├── plans/ # Architecture documentation
└── Cargo.toml # Workspace configuration
The viewer uses ray marching with signed distance functions (SDFs) to render 3D fractals. Each pixel:
- Casts a ray from the camera
- Marches along the ray, evaluating the SDF at each step
- Stops when the distance is below epsilon (hit) or exceeds max distance (miss)
- Calculates normal, lighting, and coloring
Shaders are written in WGSL (WebGPU Shading Language). The wgpu library uses Naga to transpile WGSL to:
- SPIR-V for Vulkan (Windows, Linux, Android)
- MSL for Metal (macOS, iOS)
- HLSL for DirectX 12 (Windows)
- WGSL for WebGPU (browsers)
For deep zoom, we use double-single arithmetic - representing numbers as hi + lo where hi and lo are both f32. This provides ~14 digits of precision instead of ~7.
For build commands, architecture, features, and conventions, see the Development Guide.
For testing instructions and the full test inventory, see the Testing Guide.
MIT License
