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/gaussian_blur.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/gaussian_blur.wgsl')
| -rw-r--r-- | assets/final/shaders/gaussian_blur.wgsl | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/assets/final/shaders/gaussian_blur.wgsl b/assets/final/shaders/gaussian_blur.wgsl index e848c6b..39cbf54 100644 --- a/assets/final/shaders/gaussian_blur.wgsl +++ b/assets/final/shaders/gaussian_blur.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 { strength: f32, _pad: 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,16 +26,16 @@ 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; var res = vec4<f32>(0.0); // Parameterized strength + dramatic beat pulsation - let pulse = 0.5 + uniforms.intensity * 2.0; // Pulsate between 0.5x and 2.5x with beat - let size = uniforms.strength * pulse; + let pulse = 0.5 + common.audio_intensity * 2.0; // Pulsate between 0.5x and 2.5x with beat + let size = params.strength * pulse; for (var x: f32 = -2.0; x <= 2.0; x += 1.0) { for (var y: f32 = -2.0; y <= 2.0; y += 1.0) { - res += textureSample(txt, smplr, uv + vec2<f32>(x, y) * size / uniforms.width); + res += textureSample(txt, smplr, uv + vec2<f32>(x, y) * size / common.resolution.x); } } return res / 25.0; |
