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
npm install
npm run dev
The project includes an explicit Cargo workspace boundary, so it remains independent from any Cargo.toml above its folder.
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.
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.
The fragment shader includes:
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.
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.
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.
Background choices are transparent, black, white, and checkerboard.
The app exports the current decoded frame as:
Available sizes:
MAX_VIEWPORT_DIMSThe 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.
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