From de9bc553ed0e8bda42057ac441936c20a8185f60 Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 21 Feb 2026 09:44:17 +0100 Subject: refactor(wgsl): Use vec*f alias for vector types Replaces all instances of `vec` with the more concise `vec*f` alias (e.g., `vec3f`) across all `.wgsl` shaders. This improves readability and aligns with common graphics programming conventions. Also adds a new coding style rule to `doc/CODING_STYLE.md` to enforce this standard going forward. Finally, this commit fixes a build error in `test_effect_base.cc` by replacing a call to the non-existent `wgpuDeviceTick` with `wgpuDevicePoll`, which resolves the test failure. --- workspaces/main/shaders/sdf_test.wgsl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'workspaces/main/shaders/sdf_test.wgsl') diff --git a/workspaces/main/shaders/sdf_test.wgsl b/workspaces/main/shaders/sdf_test.wgsl index 3c97613..3b63fef 100644 --- a/workspaces/main/shaders/sdf_test.wgsl +++ b/workspaces/main/shaders/sdf_test.wgsl @@ -10,27 +10,27 @@ @group(0) @binding(1) var camera: CameraParams; // Scene distance function -fn df(p: vec3) -> f32 { +fn df(p: vec3f) -> f32 { // Animated sphere - let sphere_pos = vec3(sin(uniforms.beat_time * 0.5) * 2.0, 0.0, 0.0); + let sphere_pos = vec3f(sin(uniforms.beat_time * 0.5) * 2.0, 0.0, 0.0); let d_sphere = sdSphere(p - sphere_pos, 1.0); // Static box - let box_pos = vec3(0.0, -2.0, 0.0); - let d_box = sdBox(p - box_pos, vec3(3.0, 0.5, 3.0)); + let box_pos = vec3f(0.0, -2.0, 0.0); + let d_box = sdBox(p - box_pos, vec3f(3.0, 0.5, 3.0)); return min(d_sphere, d_box); } // Simple lighting -fn shade(pos: vec3, rd: vec3) -> vec3 { +fn shade(pos: vec3f, rd: vec3f) -> vec3f { let n = normal(pos); - let light_dir = normalize(vec3(1.0, 1.0, -1.0)); + let light_dir = normalize(vec3f(1.0, 1.0, -1.0)); let diff = max(dot(n, light_dir), 0.0); let amb = 0.2; // Color based on position - let col = mix(vec3(0.2, 0.6, 0.9), vec3(0.9, 0.3, 0.2), + let col = mix(vec3f(0.2, 0.6, 0.9), vec3f(0.9, 0.3, 0.2), smoothstep(-2.0, 2.0, pos.x)); return col * (diff + amb); @@ -56,7 +56,7 @@ fn fs_main(@builtin(position) pos: vec4) -> @location(0) vec4 { let t = rayMarch(ray.origin, ray.direction, 0.0); // Background color - var col = vec3(0.1, 0.1, 0.15); + var col = vec3f(0.1, 0.1, 0.15); // Shade hit point if (t < MAX_RAY_LENGTH) { -- cgit v1.2.3