From e6c2e5418d67e9b4d12d2da74a81fc57e1147865 Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 8 Feb 2026 22:44:37 +0100 Subject: feat(shaders): Standardize all shaders to use CommonUniforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Define CommonUniforms struct with standard fields: - resolution: vec2 - 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 --- assets/final/shaders/gaussian_blur.wgsl | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'assets/final/shaders/gaussian_blur.wgsl') 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; -struct Uniforms { +struct CommonUniforms { + resolution: vec2, + 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 uniforms: Uniforms; +@group(0) @binding(2) var common: CommonUniforms; +@group(0) @binding(3) var params: EffectParams; @vertex fn vs_main(@builtin(vertex_index) i: u32) -> @builtin(position) vec4 { var pos = array, 3>( @@ -24,16 +26,16 @@ struct Uniforms { } @fragment fn fs_main(@builtin(position) p: vec4) -> @location(0) vec4 { - let uv = p.xy / vec2(uniforms.width, uniforms.height); + let uv = p.xy / common.resolution; var res = vec4(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(x, y) * size / uniforms.width); + res += textureSample(txt, smplr, uv + vec2(x, y) * size / common.resolution.x); } } return res / 25.0; -- cgit v1.2.3