summaryrefslogtreecommitdiff
path: root/src/effects/distort.wgsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/effects/distort.wgsl')
-rw-r--r--src/effects/distort.wgsl20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/effects/distort.wgsl b/src/effects/distort.wgsl
new file mode 100644
index 0000000..e19bd16
--- /dev/null
+++ b/src/effects/distort.wgsl
@@ -0,0 +1,20 @@
+@group(0) @binding(0) var smplr: sampler;
+@group(0) @binding(1) var txt: texture_2d<f32>;
+
+#include "common_uniforms"
+
+struct DistortParams {
+ strength: f32,
+ speed: f32,
+};
+
+@group(0) @binding(2) var<uniform> uniforms: CommonUniforms;
+@group(0) @binding(3) var<uniform> params: DistortParams;
+
+#include "render/fullscreen_vs"
+
+@fragment fn fs_main(@builtin(position) p: vec4f) -> @location(0) vec4f {
+ let uv = p.xy / uniforms.resolution;
+ let dist = params.strength * uniforms.audio_intensity * sin(uv.y * 20.0 + uniforms.time * params.speed * 5.0);
+ return textureSample(txt, smplr, uv + vec2f(dist, 0.0));
+}