diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-28 02:39:04 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-28 02:39:04 +0100 |
| commit | 472c2258dbeca000a454ea1781f09df63477563e (patch) | |
| tree | 98ac75c3824f19f4a598a807b3cb6aa13e8cb0c3 /common/shaders/math/common_utils.wgsl | |
| parent | 1c5a9fb7b8c704a59ec58894adf46d73d1615072 (diff) | |
replace wgsl type: vec4<f32> -> vec4f ..
Diffstat (limited to 'common/shaders/math/common_utils.wgsl')
| -rw-r--r-- | common/shaders/math/common_utils.wgsl | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/common/shaders/math/common_utils.wgsl b/common/shaders/math/common_utils.wgsl index b8446b4..6ebc25a 100644 --- a/common/shaders/math/common_utils.wgsl +++ b/common/shaders/math/common_utils.wgsl @@ -6,28 +6,28 @@ 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: vec3f) -> vec3f { - let normal_matrix = mat3x3<f32>(inv_model[0].xyz, inv_model[1].xyz, inv_model[2].xyz); +fn transform_normal(inv_model: mat4x4f, normal_local: vec3f) -> vec3f { + let normal_matrix = mat3x3f(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: vec3f) -> vec2<f32> { +fn spherical_uv(p: vec3f) -> vec2f { 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); + return vec2f(u, v); } // Spherical UV from direction vector (for skybox, etc.) -fn spherical_uv_from_dir(dir: vec3f) -> vec2<f32> { +fn spherical_uv_from_dir(dir: vec3f) -> vec2f { 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); + return vec2f(u, v); } // Grid pattern for procedural texturing (checkerboard-like) -fn grid_pattern(uv: vec2<f32>) -> f32 { +fn grid_pattern(uv: vec2f) -> f32 { let grid = 0.5 + 0.5 * sin(uv.x * PI) * sin(uv.y * PI); return smoothstep(0.45, 0.55, grid); } @@ -37,8 +37,8 @@ fn grid_pattern(uv: vec2<f32>) -> f32 { // Calculates normalized screen coordinates from fragment position and resolution. // Input `p` is the fragment's @builtin(position), `resolution` is the screen resolution. -// Returns a vec2<f32> in NDC space, with X adjusted for aspect ratio. -fn getScreenCoord(p: vec4<f32>, resolution: vec2<f32>) -> vec2<f32> { +// Returns a vec2f in NDC space, with X adjusted for aspect ratio. +fn getScreenCoord(p: vec4f, resolution: vec2f) -> vec2f { let q = p.xy / resolution; var coord = -1.0 + 2.0 * q; coord.x *= resolution.x / resolution.y; |
