diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-08 22:44:37 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-08 22:44:37 +0100 |
| commit | e6c2e5418d67e9b4d12d2da74a81fc57e1147865 (patch) | |
| tree | b5879186fb6717b59a62a4e341425fea3d4e398f /assets/final/shaders/chroma_aberration.wgsl | |
| parent | 1b89a26a750cc32725564a0c5186a437f372fd93 (diff) | |
feat(shaders): Standardize all shaders to use CommonUniforms
Define CommonUniforms struct with standard fields:
- resolution: vec2<f32>
- aspect_ratio: f32
- time: f32
- beat: f32
- audio_intensity: f32
Updated 14 shaders to use CommonUniforms:
- Replaced width/height with resolution
- Unified intensity/audio_peak → audio_intensity
- Moved effect-specific params to EffectParams struct
- visual_debug.wgsl now uses GlobalUniforms.view_proj
All shaders now have consistent uniform interface.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'assets/final/shaders/chroma_aberration.wgsl')
| -rw-r--r-- | assets/final/shaders/chroma_aberration.wgsl | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/assets/final/shaders/chroma_aberration.wgsl b/assets/final/shaders/chroma_aberration.wgsl index f1a3034..ca1e17d 100644 --- a/assets/final/shaders/chroma_aberration.wgsl +++ b/assets/final/shaders/chroma_aberration.wgsl @@ -1,18 +1,20 @@ @group(0) @binding(0) var smplr: sampler; @group(0) @binding(1) var txt: texture_2d<f32>; -struct Uniforms { +struct CommonUniforms { + resolution: vec2<f32>, + aspect_ratio: f32, time: f32, beat: f32, - intensity: f32, - aspect_ratio: f32, - width: f32, - height: f32, + audio_intensity: f32, +}; +struct EffectParams { offset_scale: f32, angle: f32, }; -@group(0) @binding(2) var<uniform> uniforms: Uniforms; +@group(0) @binding(2) var<uniform> common: CommonUniforms; +@group(0) @binding(3) var<uniform> params: EffectParams; @vertex fn vs_main(@builtin(vertex_index) i: u32) -> @builtin(position) vec4<f32> { var pos = array<vec2<f32>, 3>( @@ -24,11 +26,11 @@ struct Uniforms { } @fragment fn fs_main(@builtin(position) p: vec4<f32>) -> @location(0) vec4<f32> { - let uv = p.xy / vec2<f32>(uniforms.width, uniforms.height); + let uv = p.xy / common.resolution; // Compute offset magnitude and direction - let offset_mag = uniforms.offset_scale * uniforms.intensity; - let offset_dir = vec2<f32>(cos(uniforms.angle), sin(uniforms.angle)); + let offset_mag = params.offset_scale * common.audio_intensity; + let offset_dir = vec2<f32>(cos(params.angle), sin(params.angle)); let offset = offset_mag * offset_dir; // Sample RGB channels with chromatic aberration |
