Skip to content

Modular fractal shader system using Bevy and Shadplay. Advanced GPU-accelerated fractal rendering and shader development.

Notifications You must be signed in to change notification settings

compiling-org/rust-fractal-shader-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

24 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Modular Fractal Shader โ€” Current State (November 2025)

A modular fractal generator built with Rust and Bevy. This README reflects the actual implementation status and serves as a living document that evolves with the code.

๐Ÿš€ Status Overview

  • โœ… Bevy 0.17 + bevy_egui integration for desktop GUI
  • โœ… Core fractal engine with CPU-based distance estimation (Mandelbrot, Julia, Mandelbulb, Mandelbox, more)
  • โœ… Basic viewport and parameter panels
  • ๐Ÿšง GPU renderer integration (WGSL compute/render) in progress
  • ๐Ÿšง Node system: data model implemented; editor UI not implemented yet
  • ๐Ÿšง Export: placeholder mesh/image exporters (non-fractal meshes)
  • ๐Ÿšง Animation: keyframe/timeline structures present; no timeline UI yet
  • โŒ Advanced features (GI, volumes, VR/AR, gesture, NFT) not implemented

๐Ÿ“š Whatโ€™s Implemented vs Planned

Implemented

  • Fractal mathematics and distance estimation in src/fractal/engine.rs
  • Bevy-based GUI scaffolding in src/gui.rs with viewport texture binding
  • Basic parameter handling, color palettes, and metrics

Partial

  • GPU/WGPU setup with backend preflight and logging
  • Viewport image binding for Camera3d โ†’ egui texture
  • Exporters stubbed (OBJ/STL/PLY ASCII basics)

Planned

  • Visual node editor (drag-and-drop, connectors, groups)
  • GPU compute path for fractal evaluation and shading
  • Timeline editor, audio/MIDI integration
  • Proper mesh extraction from DE fields and voxel formats

๐Ÿงญ Architecture (High Level)

flowchart LR
    A[GUI (Bevy + bevy_egui)] --> B[FractalStudioApp]
    B --> C[Fractal Engine (CPU)]
    B --> D[Renderer (GPU/WGPU) ~ in progress]
    B --> E[Node System (data model)]
    B --> F[Animation (structures)]
    B --> G[Export (placeholders)]
    C -->|DE results| D
    E -->|Graphs/Params| C
    F -->|Param drives| C
    G -->|Images/Meshes| H[Disk]
Loading

โœจ Features (Honest Snapshot)

Fractal Generation

  • โœ… 2D: Mandelbrot, Julia, Burning Ship, Tricorn
  • โœ… 3D: Mandelbulb, Mandelbox; distance estimators on CPU
  • ๐Ÿšง Quaternion Julia, Kaleidoscopic IFS: basic math present

Controls

  • โœ… Real-time parameter updates (iterations, bailout, palette, etc.)
  • ๐Ÿšง Camera controls and lighting: minimal; PBR pipeline not wired

Node-Based System

  • โœ… Data model: Node, NodeGraph, NodeConnection, DataType
  • โœ… Generators/Math/Color/Transform/Output enums
  • ๐Ÿšง Execution logic is simplified; editor UI missing
  • โžœ See docs/NODE_SYSTEM.md for details and roadmap

Rendering & Performance

  • โœ… Ray-marching math and DE routines on CPU
  • ๐Ÿšง WGSL shaders and GPU path wiring
  • ๐Ÿšง Adaptive quality and performance presets

Export

  • ๐Ÿšง ASCII OBJ/STL/PLY basics; placeholder cube export
  • ๐Ÿšง Snapshot PNG pipeline (alpha)

Platform

  • โœ… Desktop (Windows/macOS/Linux)
  • โ„น๏ธ Web/WASM lives elsewhere; see docs/PLATFORM_SPLIT.md

๐Ÿ“ฆ Installation

Rust Bevy License

โœจ Features

๐ŸŽจ Fractal Generation

  • 2D Fractals: Mandelbrot, Julia, Burning Ship, Tricorn, Phoenix
  • 3D Fractals: Mandelbulb, Mandelbox, Menger Sponge, Quaternion Julia
  • Hybrid Fractals: BulbBox, Amazing Box, Kaleidoscopic IFS
  • Procedural: Generic spirals, torus, helix, vortex patterns
  • Distance Estimation: GPU-accelerated real-time rendering

๐ŸŽ›๏ธ Interactive Control System

  • Real-time Parameters: Zoom, iterations, power, bailout, rotation
  • Color Control: Customizable palettes and gradient mapping
  • Transform Controls: Position, scale, rotation, folding parameters
  • Fractal-specific: Mandelbulb power, Mandelbox folding, IFS transforms

๐ŸŽฏ Node-Based Composition

  • Visual Node Editor: Drag-and-drop fractal composition
  • Generator Nodes: 2D/3D fractals, noise, mathematical functions
  • Transform Nodes: Position, scale, rotate, warp operations
  • Effect Nodes: Color correction, geometry transforms, filters
  • Animation Nodes: Timeline control, LFO oscillators, noise generators

๐Ÿš€ Performance & Compatibility

  • GPU Acceleration: WebGPU/Vulkan/Metal/DX12 support
  • Real-time Rendering: 60+ FPS on modern GPUs
  • Cross-Platform: Windows, macOS, Linux (desktop-only)
  • Memory Efficient: Optimized resource management

๐ŸŽฌ Animation & Motion

  • Keyframe Animation: Professional timeline with interpolation
  • Procedural Animation: L-systems, noise, attractors
  • Camera Animation: Cinematic camera movement
  • Parameter Automation: Dynamic fractal parameter changes

๐ŸŽจ Rendering Pipeline

  • Ray Marching: Real-time distance field rendering
  • Adaptive Quality: Automatic LOD based on performance
  • Professional Viewport: 3D navigation and camera controls
  • Material System: PBR materials with metallic/roughness workflow

๐Ÿ“บ Real-time Output

  • Multi-Display: Support for complex display setups
  • Viewport Controls: Professional camera and navigation tools
  • Interactive Controls: Real-time parameter adjustment
  • Export Preview: WYSIWYG export preparation

๐ŸŽฎ Professional UI/UX

  • Dark Theme: Modern dark interface with glassmorphism
  • Customizable Workspaces: Multiple layout configurations
  • Context Menus: Right-click context-sensitive actions
  • Keyboard Shortcuts: Efficient workflow optimization

๐Ÿ“ฆ Installation

Prerequisites

  • Rust 1.70+
  • Vulkan/Metal/DX12 compatible GPU
  • Audio device (optional, for audio features)
  • MIDI device (optional, for MIDI control)

From Source

git clone https://github.com/compiling-org/modular-fractal-shader
cd modular-fractal-shader
cargo build --release

Documentation Suite

  • docs/FEATURES_STATUS.md โ€” Implemented vs partial vs planned (living)
  • docs/NODE_SYSTEM.md โ€” Node system design, status, diagrams
  • docs/DEVELOPMENT_PLAN.md โ€” Phases, goals, acceptance criteria
  • docs/DEVELOPMENT_ROADMAP.md โ€” Milestones and priorities
  • docs/DOCS_MAINTENANCE.md โ€” Update cadence and protocols

Documents are living and updated alongside code changes.

โš ๏ธ GPU Policy

  • Prefer discrete GPU; logs diagnostics and continues if unavailable
  • Backend preflight sets WGPU_BACKEND and compiler hints on Windows
  • Recommended environment configuration before running:
    • Windows: WGPU_BACKEND=vulkan,dx12, WGPU_POWER_PREF=high, WGPU_DX12_COMPILER=fxc
    • macOS: WGPU_BACKEND=metal, WGPU_POWER_PREF=high
    • Linux: WGPU_BACKEND=vulkan, WGPU_POWER_PREF=high
  • See gpu_startup.log after launch for adapter diagnostics

Required Run Commands

  • PowerShell (Windows):
$env:WGPU_BACKEND = 'vulkan,dx12'
$env:WGPU_POWER_PREF = 'high'
$env:WGPU_DX12_COMPILER = 'fxc'
cargo run --features gui
  • Git Bash (Windows):
export WGPU_BACKEND='vulkan,dx12'
export WGPU_POWER_PREF='high'
export WGPU_DX12_COMPILER='fxc'
cargo run --features gui
  • macOS/Linux:
export WGPU_BACKEND='metal'   # macOS
export WGPU_BACKEND='vulkan'  # Linux
export WGPU_POWER_PREF='high'
cargo run --features gui

If the app exits with a message about โ€œGPU device not available โ€” GPU-only policy enforced,โ€ verify drivers and backend selection.

Docs-First Workflow

  • Update relevant docs in the same PR as code changes
  • Use status tags: Implemented / Partial / Planned
  • Keep docs/FEATURES_STATUS.md and docs/NODE_SYSTEM.md current

Track Current Issues:

  • Known problems and planned fixes live in docs/ISSUES_TRACKER.md.
  • When you discover a new issue or change an issueโ€™s status, update the tracker in the same PR.
  • Keep repro steps and acceptance criteria precise; this makes triage and validation fast.

๐ŸŽฎ Usage

Basic Usage

# Start GUI application
cargo run

# Run performance benchmarks
cargo run -- benchmark

# Run compatibility tests
cargo run -- test

Fragment Pseudoโ€‘3D Mode (Experimental)

The fragment path is exploratory and not wired to production UI. Expect limited functionality.

DEโ†’Color Mapping (Alpha)

  • Modes: off, grayscale by depth, multiply base
  • Parameters exist; UI and shader wiring are evolving

Node Editor Demo

cargo run --example node_editor_demo

Fractal Rendering Demo

cargo run --example fractal_demo

CLI Mesh Export (alpha)

# Export a placeholder OBJ mesh (cube) to exports/mesh.obj
cargo run --bin mesh_export -- --output exports/mesh.obj --width 32 --height 32 --depth 32
  • Current behavior exports a placeholder cube (non-fractal)
  • Intended roadmap: load a .fract project, evaluate scene objects, and export meshes per object parameters.
  • Flags: --output <path>, --width <w>, --height <h>, --depth <d> (defaults: exports/mesh.obj, 32, 32, 32).

CLI Snapshot (alpha)

Render a single PNG using the CPU path; WGSL integration is in progress.

# Default snapshot (1024x768, Mandelbulb)
cargo run --bin fractal-snapshot

# Snapshot with camera, lighting, DEโ†’color, and tonemapping controls
cargo run --bin fractal-snapshot -- '{
  "width": 1024,
  "height": 768,
  "formula": "mandelbulb",
  "camera_fov": 60.0,
  "light_direction": [0.4, 0.7, -0.2],
  "light_color": [0.8, 0.9, 1.0],
  "light_intensity": 1.0,
  "material_metallic": 0.0,
  "material_roughness": 0.5,
  "de_color_mode": 1,
  "de_color_scale": 0.2,
  "tonemap": "reinhard",
  "exposure": 1.2,
  "output": "snapshot.png"
}'
  • DEโ†’color: de_color_mode (0 off, 1 grayscale by depth, 2 multiply base), de_color_scale (depth scale).
  • Tonemapping: tonemap (none | reinhard), exposure (positive float).
  • Camera & lighting: camera_fov (degrees), light_direction (xyz), light_color (rgb), light_intensity, material_metallic, material_roughness.

Platform Split

Desktop-only in this repository. Web/WASM builds live in NUWE; see docs/PLATFORM_SPLIT.md.

Web Deployment

  • The browser/WASM edition lives in the NUWE blockchain project.
  • This repo focuses on native desktop builds; web API/UI code is relocated.
  • For details and links to the web codebase, see docs/PLATFORM_SPLIT.md.

๐Ÿ—๏ธ Modules

  • FractalEngine โ€” CPU DE math and coloring
  • Renderer โ€” WGSL shaders and GPU wiring (in progress)
  • Nodes โ€” Data model and execution stubs
  • Animation โ€” Keyframe/timeline structures
  • Scene โ€” Cameras and basic 3D setup
  • Export โ€” ASCII mesh/image placeholders
classDiagram
    class FractalEngine {
      +compute_distance(vec3) DistanceResult
      +parameters : FractalParameters
    }
    class Renderer {
      +initialize_wgpu(device, queue)
      +fractal_compute.wgsl
    }
    class NodeGraph {
      +nodes : HashMap
      +connections : Vec
      +execute(context) NodeResult
    }
    FractalEngine <.. Renderer
    NodeGraph --> FractalEngine
Loading

๐ŸŽจ Node Types (Implemented)

  • Generators: Mandelbrot, Julia, Mandelbulb, Mandelbox, IFS (data model)
  • Math: Add, Multiply, Sine, Cosine, Absolute, etc.
  • Color: Invert, Brightness (basic)
  • Transform: Scale (basic)
  • Output: Pass-through

See docs/NODE_SYSTEM.md for full details and planned nodes.

๐Ÿ”ง Development

Building

# Debug build
cargo build

# Release build (optimized)
cargo build --release

# Run tests
cargo test

# Run examples
cargo run --example node_editor_demo
cargo run --example fractal_demo

Project Structure

src/
โ”œโ”€โ”€ main.rs              # Application entry point
โ”œโ”€โ”€ lib.rs               # Library interface
โ”œโ”€โ”€ gui.rs               # Bevy GUI implementation
โ”œโ”€โ”€ fractal/             # Fractal engine
โ”‚   โ”œโ”€โ”€ mod.rs
โ”‚   โ”œโ”€โ”€ engine.rs
โ”‚   โ”œโ”€โ”€ formulas.rs
โ”‚   โ”œโ”€โ”€ renderer.rs
โ”‚   โ””โ”€โ”€ types.rs
โ”œโ”€โ”€ ui/                  # User interface
โ”‚   โ”œโ”€โ”€ mod.rs
โ”‚   โ”œโ”€โ”€ main.rs
โ”‚   โ”œโ”€โ”€ node_editor.rs
โ”‚   โ”œโ”€โ”€ theme.rs
โ”‚   โ””โ”€โ”€ fractal_ui.rs
โ”œโ”€โ”€ scene/               # 3D scene management
โ”‚   โ””โ”€โ”€ mod.rs
โ”œโ”€โ”€ animation/           # Animation system
โ”‚   โ”œโ”€โ”€ mod.rs
โ”‚   โ”œโ”€โ”€ timeline.rs
โ”‚   โ””โ”€โ”€ keyframe.rs
โ”œโ”€โ”€ export/              # Export functionality
โ”‚   โ””โ”€โ”€ mod.rs
โ”œโ”€โ”€ benchmark.rs         # Performance benchmarking
โ”œโ”€โ”€ project.rs           # Project management
โ””โ”€โ”€ nodes.rs             # Node definitions

docs/                    # Documentation
examples/                # Example applications
assets/                  # Shaders and resources

๐ŸŽฏ Roadmap (Condensed)

  • Foundation: GPU renderer, node editor UI, mesh export from DE
  • Core: timeline editor, audio/MIDI, camera+lighting controls
  • Advanced: volumes, GI, VR/AR, collaboration, plugins

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Guidelines

  1. Follow Rust coding standards
  2. Add tests for new features
  3. Update documentation
  4. Ensure cross-platform compatibility

Docs-First Workflow (Required)

  • All code changes must be paired with documentation updates.
  • CI includes a Docs Gate that fails PRs with code changes unless docs/ files are updated.
  • PRs must link updated docs and acceptance criteria (see .github/PULL_REQUEST_TEMPLATE.md).
  • Commit messages should include a Docs: section or links to updated docs. Use Doc-Exempt only for trivial infra/typo commits.

Install Git Hooks (Windows)

  • Install local hooks to enforce docs-first commits:
    • PowerShell: powershell -ExecutionPolicy Bypass -File scripts/install_hooks.ps1
    • Or: pwsh -File scripts/install_hooks.ps1
  • Hooks installed: pre-commit (blocks code-only commits), commit-msg (nudges to include docs context).

Required Docs to Update

  • At least one of:
    • docs/DEVELOPMENT_PLAN.md
    • docs/DEVELOPMENT_ROADMAP.md
    • docs/GAP_ASSESSMENT.md
    • Relevant module plans (e.g., docs/VR_XR_INTEGRATION_PLAN.md, docs/GESTURE_INPUT_PLAN.md)
  • Reference: docs/DOCS_MAINTENANCE.md โ€” Living Docs Protocol and automation.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Bevy Engine - For the amazing Rust game engine
  • WebGPU/WGSL - For modern GPU compute capabilities
  • Rust Community - For the excellent ecosystem
  • Fractal Community - For the inspiration and algorithms

๐Ÿ“ž Contact


Made with โค๏ธ and lots of fractals

Desktop UI Theme Controls

  • The project is desktop-focused; no server or web preview is required.
  • See docs/THEME_CONTROLS.md for usage and implementation details.

About

Modular fractal shader system using Bevy and Shadplay. Advanced GPU-accelerated fractal rendering and shader development.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •