junkpile

18 · Tauri v1 Texture Mixer

A standalone Tauri v1 + raw WebGL example for compositing two independent image or video sources in one fragment-shader pass.

The exact folder name is:

18-tauri-v1-texture-mixer

What this example teaches

Run

npm install
npm run dev

The project includes an explicit Cargo workspace boundary, so it remains independent from any Cargo.toml above its folder.

Inputs

Layer A and Layer B each accept WebView-supported:

Videos are muted, looped, and played inline. This avoids accidental audio monitoring and keeps the example focused on texture compositing. Each video has independent play/pause and playback-speed controls.

The app launches with two generated images, so every blend and mask control can be tested before loading media.

Per-layer controls

Select Layer A or Layer B in the transform section, then adjust:

Swap A ↔ B exchanges the complete source state, including media, transform, opacity, and video transport state.

Blend modes

The fragment shader includes:

  1. Normal
  2. Add
  3. Multiply
  4. Screen
  5. Overlay
  6. Hard light
  7. Difference
  8. Exclusion
  9. Lighten
  10. Darken
  11. Color dodge

The Mix control determines how strongly Layer B and the selected blend operation affect the result.

Auto crossfade replaces the fixed mix amount with a sinusoidal animation. The crossfade happens in the shader; the slider itself does not move or produce a jumpy interface.

Masks

Layer B can be limited by:

Mask controls include threshold, feathering, scale, angle, center position, and inversion.

The Mask preview mode renders the final mask as grayscale, which makes it easier to understand why part of Layer B is or is not visible.

Render path

Layer A image/video ──► WebGL texture A ──► transform A ──┐
                                                         ├─► blend mode ─► mask ─► canvas
Layer B image/video ──► WebGL texture B ──► transform B ──┘

Both sources are sampled in one WebGL 1 fragment shader. No CPU pixel compositing occurs during normal rendering.

For video sources, the current decoded frame is uploaded with texImage2D() before drawing. Images are uploaded once and reused.

Preview modes

Background choices are transparent, black, white, and checkerboard.

Export

The app exports the current decoded frame as:

Available sizes:

The export is rendered at the selected dimensions rather than scaling a screenshot of the window. The currently selected background is included.

Tauri permissions are intentionally limited to:

If the Tauri global APIs are unavailable, the frontend falls back to a normal browser download.

Presets

Project structure

18-tauri-v1-texture-mixer/
├── package.json
├── README.md
├── V1-FOLDER-MAP.md
├── src/
│   ├── index.html
│   ├── styles.css
│   └── app.js
└── src-tauri/
    ├── Cargo.toml
    ├── build.rs
    ├── tauri.conf.json
    ├── icons/
    └── src/
        └── main.rs

Notes