A high-performance, interactive Mandelbrot set renderer with real-time GPU acceleration, multi-threaded CPU rendering, 3D visualization, and an intuitive user interface.
Additionally, this is an exercise in vibe coding using Anthropic's Claude Code. I wanted to see how this works and how to improve the outcomes. Besides this, it's an interesting way to learn several new technologies, like Odin itself, shader programming, and ImGui. Definitely worth the trial.
- 2D Mode: Classic flat fractal rendering with color mapping
- 3D Mode: Revolutionary column-based visualization where iteration depth becomes physical height
- Instanced rendering with millions of 3D columns
- Orbital camera with full 6-DOF control (rotate, pan, zoom)
- Real-time Phong lighting with adjustable parameters
- Explore the Mandelbrot set as a three-dimensional landscape
- GPU Fragment Shader: Real-time interactive display using OpenGL 3.3+ (50-100x faster than single-threaded CPU)
- GPU Compute Shader: High-resolution exports using OpenGL 4.3+ compute shaders (100-1000x faster for exports)
- CPU Rendering: Multi-threaded SIMD vectorized computation with dynamic load balancing (16-24x speedup)
- Toggle between modes at runtime to compare performance
- External Palette System: Load custom color palettes from JSON files
- Smooth Coloring: Continuous iteration counts for gradient color transitions without banding
- View Rotation: Rotate the fractal view by any angle (0-360Β°)
- Multiple preset palettes included: Classic, Fire, Ice, Ocean, Sunset, Grayscale, Psychedelic
- Mouse Wheel Zoom: Smooth zooming centered on cursor position
- Click to Recenter: Single-click to center the view on any point
- Pan with Drag: Right-click and drag to pan the view
- Box Zoom: Shift + drag to select and zoom into a specific region
- Keyboard Controls: Arrow keys, Page Up/Down, rotation keys
- History Navigation: Browser-style back/forward through your exploration
- Bookmarks: Save and reload your favorite locations
- Ultra-Fast GPU Export: Export up to 16K resolution (132 megapixels) in under 3 seconds
- Background Export: CPU exports run in separate thread - UI stays responsive during export
- Real-Time Progress: Live progress bar with stage tracking (Computing β Encoding β Complete)
- Configurable Compression: Choose speed vs file size with 10 compression levels
- PNG Format: Lossless compression with libpng (3.6Γ faster than original implementation)
- Preset interesting locations included
- Clean tabbed interface (Controls, Bookmarks, Export)
- Real-time computation time display
- Export progress bar with stage indicators and elapsed time
- Adjustable iteration counts
- Help overlay (Press F1)
Mouse
| Action | Control |
|---|---|
| Zoom In/Out | Mouse Wheel |
| Rotate View | Ctrl + Mouse Wheel |
| Recenter | Left Click |
| Pan View | Right Click + Drag |
| Box Zoom | Shift + Left Click + Drag |
Keyboard
| Key | Action |
|---|---|
| Page Up / Down | Zoom in / out |
| Arrow Keys | Pan view |
| Shift + Arrows | Pan faster |
, (comma) |
Rotate counter-clockwise |
. (period) |
Rotate clockwise |
Mouse
| Action | Control |
|---|---|
| Rotate Camera | Left Click + Drag |
| Pan Camera Target | Right Click + Drag |
| Zoom In/Out | Mouse Wheel |
Keyboard
| Key | Action |
|---|---|
| Arrow Keys | Rotate camera (2Β° per press) |
| Shift + Arrows | Rotate faster (5Β° per press) |
| Page Up / Down | Move closer / farther |
| Shift + PgUp/PgDn | Zoom faster |
| R | Reset camera to default view |
| Key | Action |
|---|---|
| Alt + Left | Go back in history |
| Alt + Right | Go forward in history |
| Ctrl + 1 / 2 / 3 | Jump to Controls / Bookmarks / Export tab |
| Ctrl + S | Export image |
| F1 | Toggle help overlay (tabbed: 2D/3D/General) |
| ESC | Quit application |
- Odin compiler (nightly build recommended)
- OpenGL 3.3+ support (OpenGL 4.3+ recommended for compute shaders)
- SDL2 development libraries
- libpng development libraries (for optimized PNG export)
- Linux (tested on Arch Linux, should work on other distributions)
- Clone the repository:
git clone https://github.com/anagistics/mandelbrodin.git
cd mandelbrodin- Compile the stb_image libraries (one-time setup):
make -C ~/odin-linux-amd64-nightly+2025-10-05/vendor/stb/src- Build the project:
odin build . -out:mandelbrodin- Run:
./mandelbrodinFor development or troubleshooting:
odin build . -debug -out:mandelbrodinMinimum:
- CPU: Multi-core processor (2+ cores)
- GPU: OpenGL 3.3 compatible graphics card
- RAM: 2 GB
- OS: Linux
Recommended:
- CPU: 8+ core processor with AVX support
- GPU: Modern GPU with hundreds of shader cores
- RAM: 4+ GB
- OS: Linux (Arch, Ubuntu, Fedora, etc.)
The application features multiple optimization layers:
| Configuration | Speedup vs Baseline | Techniques |
|---|---|---|
| Single-threaded scalar | 1x (baseline) | Basic loop |
| Multi-threaded scalar | ~6-8x | 8 threads + loop unrolling |
| Multi-threaded SIMD | ~16-24x | 8 threads Γ 4-wide AVX vectors |
| GPU Fragment Shader | ~50-100x | Hundreds/thousands of parallel cores |
| Phase | Export Time | Improvement | Technology |
|---|---|---|---|
| Original | 1959 ms | Baseline | Single-threaded + stb_image_write |
| Phase 1 | 1691 ms | 14% faster | Multi-threaded conversion (8 threads) |
| Phase 2 | 551 ms | 72% faster (3.6Γ) | GPU compute + libpng compression |
8K Export: 7711 ms β 2170 ms (72% faster, 3.6Γ speedup)
Palettes are stored as JSON files in the palettes/ directory. Create your own by following this format:
{
"name": "My Custom Palette",
"description": "A beautiful custom color scheme",
"stops": [
{"position": 0.0, "r": 0, "g": 0, "b": 0},
{"position": 0.5, "r": 255, "g": 128, "b": 0},
{"position": 1.0, "r": 255, "g": 255, "b": 255}
]
}- Positions must be in ascending order from 0.0 to 1.0
- RGB values range from 0 to 255
- Minimum 2 color stops required
- Place the file in
palettes/and restart the application
mandelbrodin/
βββ appelman.odin # Main application and event handling
βββ app/ # Core application state and logic
βββ mandelbrot/ # Computation engines (scalar, SIMD)
βββ renderer/ # OpenGL rendering and export
β βββ renderer.odin # 2D rendering and exports
β βββ renderer_3d.odin # 3D instanced rendering
β βββ camera.odin # 3D orbital camera system
βββ visual/ # Palette and coloring systems
βββ ui/ # User interface components
β βββ control_panel.odin # Main controls and mode switching
β βββ help_overlay.odin # Tabbed help screen (F1)
β βββ ... # Other UI components
βββ shaders/ # GLSL shaders (fragment + compute)
β βββ mandelbrot.frag # 2D fragment shader (real-time display)
β βββ mandelbrot_compute.glsl # Compute shader (GPU exports)
β βββ mandelbrot_3d.vert # 3D vertex shader (instancing)
β βββ mandelbrot_3d.frag # 3D fragment shader (Phong lighting)
β βββ texture.* # Texture display shaders
βββ vendor_libpng/ # libpng bindings for optimized PNG export
βββ palettes/ # Color palette definitions (JSON)
βββ bookmarks/ # Saved view locations (JSON)
2D Rendering Modes:
- GPU Display Mode: Fragment shader (OpenGL 3.3+) computes Mandelbrot in real-time for interactive exploration
- GPU Export Mode: Compute shader (OpenGL 4.3+) renders high-resolution exports at 100-1000Γ speed
- CPU Mode: 8-way task parallelism with dynamic work queues and 4-wide AVX SIMD vectorization
3D Visualization (OpenGL 3.3+):
- Instanced Rendering: Single draw call renders millions of cube instances efficiently
- Height Mapping: Iteration count/brightness extracted from 2D computation β column height
- Phong Lighting: Ambient + Diffuse + Specular components for realistic appearance
- Orbital Camera: Spherical coordinates (azimuth, elevation, distance) with smooth interpolation
- Smart Input Routing: Mouse position determines whether keyboard controls viewport or UI
- Performance: Handles 800Γ600 = 480,000 columns at 60+ FPS on modern GPUs
Export Optimization:
- Multi-threaded ARGBβRGB pixel conversion (8 threads)
- libpng with configurable compression levels (0-9)
- Level 1 compression: 42-44% faster than stb_image_write with similar file sizes
- Combined optimizations: 3.6Γ faster exports than original implementation
Coordinate System:
- Proper rotation support with consistent transformations across GPU and CPU paths
- Screen-to-world coordinate conversion handles zoom, pan, and rotation
Smooth Coloring:
- Uses escape distance estimation:
smooth_iter = n + 1 - log(log(|z|)) / log(2) - Eliminates color banding for professional-quality visualization
Contributions are welcome! Areas for potential improvement:
- 3D Enhancements: Shadow mapping, 3D model export (OBJ/PLY/STL), LOD optimization
- AVX-512 Support: 8-wide vectorization for newer CPUs
- Vulkan Backend: Cross-platform GPU acceleration (Phase 3 of PLAN.md)
- Progressive Rendering: Adaptive coloring (Phase 2 of PLAN.md)
- Deep Zoom: Perturbation theory for extreme zoom levels (>10^15)
- Animation: Video export capabilities, camera path recording
This project is under the MIT license. (c) 2025 Andreas Cardeneo
Built with:
- Odin Programming Language
- SDL2 for windowing and input
- Dear ImGui for user interface
- libpng for optimized PNG export
- OpenGL 3.3+ (fragment shaders) and 4.3+ (compute shaders)
The following image is just one example of an exported image in 4K resolution.


