[![Shader Binary Release](https://github.com/altunenes/cuneus/actions/workflows/release.yaml/badge.svg)](https://github.com/altunenes/cuneus/actions/workflows/release.yaml) [![crates.io](https://img.shields.io/crates/v/Cuneus.svg)](https://crates.io/crates/Cuneus)

<img src="https://github.com/user-attachments/assets/590dbd91-5eaa-4c04-b3f9-d579924fa4c3" alt="cuneus sdf" width="320" height="120" />


A GPU compute engine for creating, tweaking, and shipping WGSL shader programs. Built on `wgpu`, `egui`, `winit` and `gstreamer` :-)

### Current Features

- Hot shader reloading
- Multi-pass
- 3DGS Rendering Inference (PLY Import, radix gpu sort)
- Interactive parameter adjustment, ez media imports through egui
- Easily use HDR textures, videos/webcam via UI
- Audio/Visual synchronization: Spectrum and BPM detection
- Real-time audio synthesis: Generate music directly from wgsl shaders
- Export HQ frames via egui
- Frame-accurate audio sync on export: pre analyzed spectrum/BPM per frame for perfect mux with the source audio

### Builder Pattern

Cuneus uses a declarative builder to configure your entire compute pipeline. You say *what* you need — the engine handles all bind group layouts, ping-pong buffers, and pipeline wiring:

```rust
// Define your multi-pass pipeline as a dependency graph:
let passes = vec![
    PassDescription::new("compute_field", &[]),               // no inputs
    PassDescription::new("render", &["compute_field"]),       // reads compute_field
    PassDescription::new("feedback", &["render", "feedback"]),// reads render + own previous frame
    PassDescription::new("main_image", &["feedback"]),
];

let config = ComputeShader::builder()
    .with_multi_pass(&passes)           // the render graph above
    .with_custom_uniforms::<MyParams>() // UI-controllable parameters
    .with_mouse()                       // mouse input
    .build();
```

Dependencies are packed sequentially — `&["render", "feedback"]` becomes `input_texture0` and `input_texture1` in WGSL. Self-reference enables cross-frame feedback (ping-pong) automatically. One `.dispatch()` call runs the entire pipeline. See [usage.md](usage.md) for the full guide.

## Current look


  <a href="https://github.com/user-attachments/assets/25d47df4-45f5-4455-b2cf-ba673a8c081c">
    <img src="https://github.com/user-attachments/assets/25d47df4-45f5-4455-b2cf-ba673a8c081c" width="300" alt="Cuneus IDE Interface"/>
  </a>

## Keys

- `F` full screen/minimal screen, `H` hide egui

#### Usage

- If you want to try your own shaders, check out the [usage.md](usage.md) and see [BUILD.md](BUILD.md).
- **Optional Media Support**: GStreamer dependencies are optional - use `--no-default-features` for lightweight builds with pure GPU compute shaders.
- **When using cuneus as a dependency** (via `cargo add`):
  - Copy [build.rs](build.rs) to your project root to configure `GStreamer` paths (only needed for media features)
  - then simply use `use cuneus::prelude::*;`


#### Run examples

- `cargo run --release --example *file*`
- Or download on the [releases](https://github.com/altunenes/cuneus/releases)


# Gallery

| **Physarum** | **JFA** | **Volumetric Passage** |
|:---:|:---:|:---:|
| <a href="https://github.com/user-attachments/assets/add8fa3d-b422-47ee-b7ce-f17a5f73b74b"><img src="https://github.com/user-attachments/assets/b9161485-3d08-437a-b6ff-c3f84b72667d" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/physarum.rs) | <a href="https://github.com/user-attachments/assets/f07023a3-0d93-4740-a95c-49f16d815e29"><img src="https://github.com/user-attachments/assets/8c71ce99-58ff-4354-9c0a-0a0fd4e5032d" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/jfa.rs) | <a href="https://github.com/user-attachments/assets/c19365ac-267f-4301-a9c8-42097d4b167a"><img src="https://github.com/user-attachments/assets/5ef301cd-cb11-4850-b013-13537939fd22" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/volumepassage.rs)|

| **PathTracing Mandelbulb** | **CNN:EMNIST** | **Path Tracing Tame Impala** |
|:---:|:---:|:---:|
| <a href="https://github.com/user-attachments/assets/24083cae-7e96-4726-8509-fb3d5973308a"><img src="https://github.com/user-attachments/assets/e454b395-a1a0-4b91-a776-9afd1a789d23" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/mandelbulb.rs) | <a href="https://github.com/user-attachments/assets/f692e325-a0d2-4ae6-9246-bcbddd85516f"><img src="https://github.com/user-attachments/assets/f692e325-a0d2-4ae6-9246-bcbddd85516f" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/cnn.rs) | <a href="https://github.com/user-attachments/assets/54dcff45-d131-4f9f-a9af-e3d3255e760c"><img src="https://github.com/user-attachments/assets/718a5ad2-323b-4486-89f0-c7187aace2fa" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/tameimp.rs) |


| **Buddhabrot** | **FFT(Butterworth filter)** | **Fluid** |
|:---:|:---:|:---:|
| <a href="https://github.com/user-attachments/assets/0dc84514-20aa-447c-a2cd-59fd77552e2f"><img src="https://github.com/user-attachments/assets/6b2e0add-c68e-460e-86a9-f42a64bd5e07" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/buddhabrot.rs) | <a href="https://github.com/user-attachments/assets/5806af3b-a640-433c-b7ec-1ca051412300"><img src="https://github.com/user-attachments/assets/e1e7f7e9-5979-43fe-8bb0-ccda8e428fe5" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/fft.rs) | <a href="https://github.com/user-attachments/assets/d828ef04-d1d8-45ff-a444-6f4e2e22e2c8"><img src="https://github.com/user-attachments/assets/f05b54a3-e7ad-4e20-8408-67365abec864" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/fluid.rs) |


| **Block Tower: 3D Game** | **GPU Synthesizer** | **2DGS:real time training** |
|:---:|:---:|:---:|
| <a href="https://github.com/user-attachments/assets/9ce52cc1-31c0-4e50-88c7-2fb06d1a57b3"><img src="https://github.com/user-attachments/assets/9ce52cc1-31c0-4e50-88c7-2fb06d1a57b3" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/blockgame.rs) | <a href="https://github.com/user-attachments/assets/3d8068c3-ce75-48c8-b606-65a287d1bcda"><img src="https://github.com/user-attachments/assets/3d8068c3-ce75-48c8-b606-65a287d1bcda" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/synth.rs) | <a href="https://github.com/user-attachments/assets/f91c7ff7-f56e-43d5-9d60-97d9c037d700"><img src="https://github.com/user-attachments/assets/f91c7ff7-f56e-43d5-9d60-97d9c037d700" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/gaussian.rs) |


| **Schwarzschild bh** | **path tracer** | **audio visualizer** |
|:---:|:---:|:---:|
| <a href="https://github.com/user-attachments/assets/d40f8822-417b-4df0-afb0-23a8c8ccebec"><img src="https://github.com/user-attachments/assets/d40f8822-417b-4df0-afb0-23a8c8ccebec" width="250" height ="200"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/blackhole.rs) | <a href="https://github.com/user-attachments/assets/45b8f532-f3fb-453c-b356-1d3c153d614a"><img src="https://github.com/user-attachments/assets/896228c3-7583-40de-9643-8b58aaec6050" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/pathtracing.rs) | <a href="https://github.com/user-attachments/assets/3eda9c33-7961-4dd4-aad1-170ae32640e7"><img src="https://github.com/user-attachments/assets/3eda9c33-7961-4dd4-aad1-170ae32640e7" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/audiovis.rs) |


| **ggxbrot** | **bugberman: 2D game** | **rorschach** |
|:---:|:---:|:---:|
| <a href="https://github.com/user-attachments/assets/c059d4b2-09a7-4431-9058-768b08302b2f"><img src="https://github.com/user-attachments/assets/8067a13c-8380-4e31-97de-90d7c72b4d22" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/orbits.rs) | <a href="https://github.com/user-attachments/assets/440d86c0-fb4d-4866-8a51-21ee995be556"><img src="https://github.com/user-attachments/assets/440d86c0-fb4d-4866-8a51-21ee995be556" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/bugberman.rs) | <a href="https://github.com/user-attachments/assets/30a3d085-42e9-4285-ac71-276fdf300164"><img src="https://github.com/user-attachments/assets/30a3d085-42e9-4285-ac71-276fdf300164" width="250"/></a><br/>[Code](https://github.com/altunenes/cuneus/blob/main/examples/rorschach.rs) |
