A Rust port of Hydra — the live-codable video synthesizer created by Olivia Jack. Takes Rhai scripts, compiles them to GLSL shaders, and renders them via OpenGL. The core is a library with zero GUI dependencies, suitable for embedding. A standalone binary is included for testing and standalone use. Originally extracted from Sova, the polyglot live coding sequencer.
| Category | Functions |
|---|---|
| Sources | osc, noise, voronoi, shape, gradient, solid, rings, checker |
| Geometry | rotate, scale, scroll, kaleid, pixelate, repeat, scrollX, scrollY, repeatX, repeatY, polar, cart, fold |
| Color | color, invert, contrast, brightness, saturate, hue, posterize, luma, colorama, shift, thresh, r, g, b |
| Blend | add, mult, blend, diff, layer, mask, sub |
| Modulate | modulate, modulateScale, modulateRotate, modulateRepeat, modulateRepeatX, modulateRepeatY, modulateKaleid, modulateScrollX, modulateScrollY, modulatePixelate, modulateHue |
| Other | text, src, initCam, fast, smooth, out, render, hush |
- 4-buffer ping-pong architecture (
o0–o3) - 4 external source slots (
s0–s3) for webcam feeds - Text rendering via bundled Hack font
- GLSL 330 (OpenGL 3.3 core profile)
- Transparent editor overlay over GL visuals
- Syntax highlighting (OneDark theme)
- File save/load (
.hydrafiles) - Session persistence
- Options sidebar (tempo, font size, text opacity)
- Toggle editor visibility with
TaborCtrl+Shift+H
- Zero GUI dependencies — only
rhai,glow, andab_glyph - Public API:
eval(code) → Result<EvalResult, String> ShaderRendererfor OpenGL multipass renderingSourceManagerfor webcam capture (4 slots)
cargo build # library only
cargo run # standalone binary
cargo test # tests
cargo clippy # lintosc(60.0, 0.1, time * 0.5)
.kaleid(4.0)
.color(1.0, 0.5, 0.3)
.modulate(noise(3.0, 0.1), 0.02)
.rotate(0.0, 0.1)
.out()
Built-in globals available as GLSL expressions: time, beat, tempo, phase, mouseX, mouseY.
hydra-rust is the visual engine of Sova, a polyglot live coding sequencer for music and visuals. In Sova, hydra shaders sync to the musical clock via beat, tempo, and phase, and can be shared across peers in multiplayer sessions.
- Rhai, not JavaScript. No closures or arrow functions. Write
osc(60.0, sin(time))directly. - Expression variables.
time,beat,tempo,phaseare GLSL uniform references, not callback functions. - Mouse input.
mouseXandmouseYare normalized to[0, 1]. - No
speedglobal. Animation speed is per-source, controlled through function arguments. - GLSL 330. Targets OpenGL 3.3 core profile.
- No video or image source loading
- No audio reactivity (FFT)
- Max nesting depth of 16