diff options
Diffstat (limited to 'test.sh')
| -rwxr-xr-x | test.sh | 52 |
1 files changed, 34 insertions, 18 deletions
@@ -1,29 +1,45 @@ #!/bin/bash +set -euo pipefail + HOST=localhost PORT=9000 +TSV_SRC=test-vid + +PIDS=() +cleanup() { + for pid in "${PIDS[@]}"; do + kill "$pid" 2>/dev/null || true + done + wait 2>/dev/null +} +trap cleanup EXIT + +spawn() { + BIN="$1" + shift + cargo run --bin "$BIN" -- "$@" & + PIDS+=($!) +} + +spawn tsv-video-stream --name "$TSV_SRC" -- \ + -f lavfi -i "testsrc=size=1920x1080:rate=60" + +spawn wgsl-render --continuous + +sleep 2 + SHADER=' -struct Uniforms { - time: f32, -}; -@group(1) @binding(0) var<uniform> u: Uniforms; +@group(1) @binding(0) var video: texture_2d<f32>; +@group(1) @binding(1) var s: sampler; @fragment fn fs_main(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> { - let p = uv * 2.0 - 1.0; - let col = 0.5 + 0.5 * cos(u.time + vec3<f32>(p.x, p.y, p.x) + vec3<f32>(0.0, 2.0, 4.0)); - return vec4<f32>(col, 1.0); + return textureSample(video, s, uv).rrra; } ' +oscsend "$HOST" "$PORT" /shader s "$SHADER" +oscsend "$HOST" "$PORT" /texture/video s "$TSV_SRC" +oscsend "$HOST" "$PORT" /sampler/sampler ss nearest clamp -echo "Loading shader..." -oscsend $HOST $PORT /shader s "$SHADER" -sleep 0.5 - -echo "Animating time uniform..." -t=0.0 -while true; do - oscsend $HOST $PORT /uniform/u/time f "$t" - t=$(echo "$t + 0.016" | bc) - sleep 0.016 -done +cargo run --bin tsv-view |
