From e38be0dbf5816338ff97e2ee2f9adfff2902dc2b Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 14 Feb 2026 15:13:09 +0100 Subject: refactor(wgsl): modularize common shader functions Extracted common WGSL functions into separate files in `common/shaders/` to improve reusability and maintainability. - Created `common/shaders/render/fullscreen_vs.wgsl` for a reusable fullscreen vertex shader. - Created `common/shaders/math/color.wgsl` for color conversion and tone mapping functions. - Created `common/shaders/math/utils.wgsl` for general math utilities. - Created `common/shaders/render/raymarching.wgsl` for SDF raymarching logic. - Updated multiple shaders to use these new common snippets via `#include`. - Fixed the shader asset validation test to correctly handle shaders that include the common vertex shader. This refactoring makes the shader code more modular and easier to manage. --- workspaces/main/shaders/distort.wgsl | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'workspaces/main/shaders/distort.wgsl') diff --git a/workspaces/main/shaders/distort.wgsl b/workspaces/main/shaders/distort.wgsl index 5d35129..607ac60 100644 --- a/workspaces/main/shaders/distort.wgsl +++ b/workspaces/main/shaders/distort.wgsl @@ -11,14 +11,7 @@ struct DistortParams { @group(0) @binding(2) var uniforms: CommonUniforms; @group(0) @binding(3) var params: DistortParams; -@vertex fn vs_main(@builtin(vertex_index) i: u32) -> @builtin(position) vec4 { - var pos = array, 3>( - vec2(-1, -1), - vec2(3, -1), - vec2(-1, 3) - ); - return vec4(pos[i], 0.0, 1.0); -} +#include "render/fullscreen_vs" @fragment fn fs_main(@builtin(position) p: vec4) -> @location(0) vec4 { let uv = p.xy / uniforms.resolution; -- cgit v1.2.3