diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-28 09:15:23 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-28 09:15:23 +0100 |
| commit | 34bee8b09566a52cedced99b7bd13d29907512ce (patch) | |
| tree | 3adda379abfd0787b24543a32f98a060f1999f00 /tools/shader_editor/SHADER_EDITOR_DETAILS.md | |
| parent | 9ee410594a52cbc699b13de2bde4860d70c959a3 (diff) | |
fix(shader_editor): sync CommonUniforms to current struct, fix layout
- Update CommonUniforms: remove _pad0/_pad1, add beat_time/beat_phase,
move _pad to end (matches src/shaders/common_uniforms.wgsl)
- Fix JS uniform write order to match new layout
- Fix flex-direction: row override (common.css forced column, hiding editor)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'tools/shader_editor/SHADER_EDITOR_DETAILS.md')
| -rw-r--r-- | tools/shader_editor/SHADER_EDITOR_DETAILS.md | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/tools/shader_editor/SHADER_EDITOR_DETAILS.md b/tools/shader_editor/SHADER_EDITOR_DETAILS.md index b8bbb25..f6fdf2e 100644 --- a/tools/shader_editor/SHADER_EDITOR_DETAILS.md +++ b/tools/shader_editor/SHADER_EDITOR_DETAILS.md @@ -18,17 +18,17 @@ All shaders receive `CommonUniforms` at `@group(0) @binding(2)`: ```wgsl struct CommonUniforms { - resolution: vec2<f32>, // Canvas width/height (1280, 720) - _pad0: f32, // Alignment padding - _pad1: f32, + resolution: vec2f, // Canvas width/height (1280, 720) aspect_ratio: f32, // resolution.x / resolution.y time: f32, // Seconds since start (resetable) - beat: f32, // Loop time 0.0→1.0 (period: 0.1-10s) + beat_time: f32, // Absolute beat counter (currentTime / loopPeriod) + beat_phase: f32, // Fractional beat 0.0→1.0 within current period audio_intensity: f32, // Manual slider 0-1 or auto-pulse + _pad: f32, // Alignment padding }; ``` -**Size:** 32 bytes (matches C++ `CommonPostProcessUniforms`) +**Size:** 32 bytes (matches `src/shaders/common_uniforms.wgsl`) ## Bind Group Specification @@ -85,12 +85,13 @@ Standard bindings for all shaders: @group(0) @binding(1) var txt: texture_2d<f32>; struct CommonUniforms { - resolution: vec2<f32>, - _pad0: f32, _pad1: f32, + resolution: vec2f, aspect_ratio: f32, time: f32, - beat: f32, + beat_time: f32, + beat_phase: f32, audio_intensity: f32, + _pad: f32, }; @group(0) @binding(2) var<uniform> uniforms: CommonUniforms; @@ -115,6 +116,7 @@ struct CommonUniforms { #include "common_uniforms" @group(0) @binding(2) var<uniform> uniforms: CommonUniforms; +// uniforms.beat_phase → fractional beat, uniforms.beat_time → absolute beats @vertex fn vs_main(@builtin(vertex_index) i: u32) -> @builtin(position) vec4<f32> { var pos = array<vec2<f32>, 3>( @@ -154,7 +156,7 @@ Animated gradient background with pulsing circle synced to `beat`: ); // Pulsing circle - let d = length(uv) - 0.3 - 0.1 * sin(uniforms.beat * 6.28); + let d = length(uv) - 0.3 - 0.1 * sin(uniforms.beat_phase * 6.28); let circle = smoothstep(0.02, 0.0, d); let glow = 0.02 / (abs(d) + 0.02); |
