diff options
Diffstat (limited to 'src/effects/chroma_aberration.wgsl')
| -rw-r--r-- | src/effects/chroma_aberration.wgsl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/effects/chroma_aberration.wgsl b/src/effects/chroma_aberration.wgsl new file mode 100644 index 0000000..02bdb1b --- /dev/null +++ b/src/effects/chroma_aberration.wgsl @@ -0,0 +1,24 @@ +@group(0) @binding(0) var smplr: sampler; +@group(0) @binding(1) var txt: texture_2d<f32>; + +#include "common_uniforms" +struct ChromaAberrationParams { + offset_scale: f32, + angle: f32, +}; + +@group(0) @binding(2) var<uniform> uniforms: CommonUniforms; +@group(0) @binding(3) var<uniform> params: ChromaAberrationParams; + +#include "render/fullscreen_vs" + +@fragment fn fs_main(@builtin(position) p: vec4f) -> @location(0) vec4f { + let uv = p.xy / uniforms.resolution; + + let amp = params.offset_scale * uniforms.audio_intensity; + let offset = amp * vec2f(cos(params.angle), sin(params.angle)); + let center = textureSample(txt, smplr, uv); + let r = textureSample(txt, smplr, uv + offset).r; + let b = textureSample(txt, smplr, uv - offset).b; + return vec4f(r, center.g, b, 1.0); +} |
