#gpu #fractals #fractal

fractl_lib

Fractal renderer supporting multithreading, gpu compute and wasm

1 unstable release

0.1.0 Jan 17, 2024

#328 in Rendering


Used in fractl_gui

GPL-3.0-or-later

1MB
1K SLoC

Rust 1K SLoC // 0.0% comments WebGPU Shader Language 130 SLoC // 0.0% comments

Fractl

  • Fractal renderer written in rust
  • Singlethreaded, multithreading (using rayon) and gpu compute (using wgpu - WebGpu implementation) versions
  • Supports both native targets and wasm
  • Currently renders the Mandelbrot set and the Multibrot set

Screenshots

Mandelbrot Multibrot

How to

  • Try the live demo (Note: the web version runs on a signle thread without GPU acceleration, native version are much faster)
  • Download a pre-build binary from ./bin
  • Install using cargo (TODO)

Controls

Key Action
LeftMouseButton Center view on cursor
WSAD Move view
R Reset view
ScrollWheel Increase / Decrease zoom
O Increase zoom
P Decrease zoom
ArrowKey Increase / Decrease zoom in a direction
T Reset zoom
K Increase percision (max iterations)
L Decrease percision (max iterations)
M Next fractal
N Previous fractal
B Next fractal coloring
V Previous fractal coloring
U Toggle UI
Y Toggle crosshair
C Increase exponent (for multi-fractals)
X Decrease exponent (for multi-fractals)
F11 Toggle Fullscreen
Escape Exit

Building using nix

  • (This should be the most reliable way)
  • Have nix installed on your system
  • Pick a package
Package Description Pararelism Floatin point percision
fractl_gui Native gui No Double (f64)
fractl_gui-multithread Native gui CPU multithreading Double (f64)
fractl_gui-gpu Native gui GPU compute shader Single (f32)
fractl_gui-wasm Web gui No Double (f64)
fractl_gui-win Native gui crosscompiled to Winows x86_64 No Double (f64)
fractl_gui-win-multithread Native gui crosscompiled to Winows x86_64 CPU multithreading Double (f64)
fractl_gui-win-gpu Native gui crosscompiled to Winows x86_64 GPU compute shader Single (f32)
  • To build: nix build .#Package

  • To build and run locally: nix run .#Package

  • Example: nix run .#gui-gpu

  • Or use on of the build scripts in ./script

Building using cargo

  • Have rust installed, or optionally use the included dev shelle: nix develop
  • Pick feautres
Feature Description Notes
multithred CPU multithreading multithread and gpu cannot be enabled at the same time
gpu GPU computing multithread and gpu, gpu and f64 cannot be enabled at the same time
f32 Single percision floating point numbers f32 and f64 cannot be enabled at the same time
f64 Double percision floating point numbers f32 and f64 cannot be enabled at the same time
  • To build: cargo build --package=fractl_gui --no-default-features --release --features "Feature1 Feature2"
  • To run: cargo run --package=fractl_gui --no-default-features --release --features "Feature1 Feature2"
  • Example: cargo build --package=fractl_gui --no-default-features --release --features "gpu f32"

TODO

  • Add Julia set, more fractals
  • F128 floating point
  • Wasm WebGpu with compute shader
  • Redox port

Dependencies

~3–39MB
~628K SLoC