A focused foundation for running a p5.js WebGL shader and its HTML controls inside one Tauri v2 WebView.
This folder intentionally retains its original repository name:
p5-tauri-v2-single-template
The visible example number is 00 so it aligns with the complete Junkpile Tauri v2 Essentials sequence.
createShader()core.invokeHTML range / checkbox
↓
params{}
↓
p5 draw loop
↓
shader.setUniform()
↓
GLSL fragment shader
↓
WebGL canvas in the same WebView
There is no WebSocket or inter-window relay. Controls and rendering share one page and one JavaScript thread.
npm install
npm run dev
npm run dev copies the pinned p5.js build from node_modules into src/vendor/ before Tauri launches. The application therefore has no runtime CDN dependency.
npm run build
On macOS, generated bundles appear under:
src-tauri/target/release/bundle/
Unsigned builds may trigger Gatekeeper on another Mac. Public distribution generally requires Apple signing and notarization.
The native shell is intentionally small:
src-tauri/src/main.rs
└── toggle_fullscreen command
src-tauri/capabilities/default.json
└── grants core access to the main WebView
src/sketch.js
└── window.__TAURI__.core.invoke("toggle_fullscreen")
Unlike the v1 counterpart, Tauri v2 uses:
frontendDist instead of devPath / distDirapp.windows instead of tauri.windowswindow.__TAURI__.core.invoke when withGlobalTauri is enabled| Section | Parameter | Purpose |
|---|---|---|
| Color | Hue shift | Rotates the shader palette |
| Color | Saturation | Moves from monochrome to vivid color |
| Color | Brightness | Multiplies final output brightness |
| Motion | Zoom | Scales shader coordinates |
| Motion | Speed | Advances the accumulated animation clock |
| Motion | Distortion | Strengthens domain warping |
| Pattern | Complexity | Changes the fBm octave count |
| Pattern | Symmetry | Changes rotational folding |
| Pattern | Glow | Brightens the center of the field |
| Switches | Invert | Inverts the final color |
| Switches | Pulse | Enables rhythmic brightness modulation |
| Switches | Rotate | Rotates the complete coordinate field |
Keyboard shortcuts:
| Key | Action |
|---|---|
| Space | Pause or resume animation |
| R | Restore defaults and reset time |
| F | Toggle native-window fullscreen |
p5-tauri-v2-single-template/
├── README.md
├── MODERNIZATION-NOTES.md
├── package.json
├── scripts/
│ └── sync-p5.mjs
├── src/
│ ├── index.html
│ ├── sketch.js
│ ├── styles.css
│ └── vendor/
│ └── p5.min.js generated after npm install
└── src-tauri/
├── capabilities/
│ └── default.json
├── Cargo.toml
├── tauri.conf.json
└── src/main.rs
<output> in src/index.html.DEFAULT_PARAMS in src/sketch.js.SLIDER_IDS.FRAG_SHADER.draw() with shaderProgram.setUniform().WebGL 1 requires fixed compile-time loop bounds. The fbm() function loops to a fixed maximum of eight iterations and exits early using the float u_complexity uniform.
pixelDensity(1) prioritizes predictable performance over retina-resolution rendering.