diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-21 09:44:17 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-21 09:50:09 +0100 |
| commit | de9bc553ed0e8bda42057ac441936c20a8185f60 (patch) | |
| tree | 1d7417510512b670bf3ce14c18020b45e5baec24 /common/shaders/math | |
| parent | e0f326e23f6b96f31ce9e8bbd5b5f2233e6a90ba (diff) | |
refactor(wgsl): Use vec*f alias for vector types
Replaces all instances of `vec<f32>` 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.
Diffstat (limited to 'common/shaders/math')
| -rw-r--r-- | common/shaders/math/common_utils.wgsl | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/common/shaders/math/common_utils.wgsl b/common/shaders/math/common_utils.wgsl index 49aaead..b8446b4 100644 --- a/common/shaders/math/common_utils.wgsl +++ b/common/shaders/math/common_utils.wgsl @@ -6,21 +6,21 @@ const PI: f32 = 3.14159265359; const TAU: f32 = 6.28318530718; // Transform normal from local to world space using inverse model matrix -fn transform_normal(inv_model: mat4x4<f32>, normal_local: vec3<f32>) -> vec3<f32> { +fn transform_normal(inv_model: mat4x4<f32>, normal_local: vec3f) -> vec3f { let normal_matrix = mat3x3<f32>(inv_model[0].xyz, inv_model[1].xyz, inv_model[2].xyz); return normalize(normal_matrix * normal_local); } // Spherical UV mapping (sphere or any radial surface) // Returns UV in [0,1] range -fn spherical_uv(p: vec3<f32>) -> vec2<f32> { +fn spherical_uv(p: vec3f) -> vec2<f32> { let u = atan2(p.x, p.z) / TAU + 0.5; let v = acos(clamp(p.y / length(p), -1.0, 1.0)) / PI; return vec2<f32>(u, v); } // Spherical UV from direction vector (for skybox, etc.) -fn spherical_uv_from_dir(dir: vec3<f32>) -> vec2<f32> { +fn spherical_uv_from_dir(dir: vec3f) -> vec2<f32> { let u = atan2(dir.z, dir.x) / TAU + 0.5; let v = asin(clamp(dir.y, -1.0, 1.0)) / PI + 0.5; return vec2<f32>(u, v); |
