Skip to content

Commit c83b83e

Browse files
committed
Use WGSL type aliases and override expressions where possible
1 parent 79a38a9 commit c83b83e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/pt/raytracer.wgsl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
struct Uniforms {
2-
viewProjectionMatrix: mat4x4<f32>,
2+
viewProjectionMatrix: mat4x4f,
33
}
44

55
@group(0) @binding(0) var<uniform> uniforms: Uniforms;
@@ -169,15 +169,15 @@ fn evalLambertian(hit: Intersection, wi: vec3f) -> vec3f {
169169
return albedo * FRAC_1_PI * max(EPSILON, dot(hit.n, wi));
170170
}
171171

172-
fn pixarOnb(n: vec3<f32>) -> mat3x3<f32> {
172+
fn pixarOnb(n: vec3f) -> mat3x3f {
173173
// https://www.jcgt.org/published/0006/01/01/paper-lowres.pdf
174174
let s = select(-1f, 1f, n.z >= 0f);
175175
let a = -1f / (s + n.z);
176176
let b = n.x * n.y * a;
177-
let u = vec3<f32>(1f + s * n.x * n.x * a, s * b, -s * n.x);
178-
let v = vec3<f32>(b, s + n.y * n.y * a, -n.y);
177+
let u = vec3(1f + s * n.x * n.x * a, s * b, -s * n.x);
178+
let v = vec3(b, s + n.y * n.y * a, -n.y);
179179

180-
return mat3x3<f32>(u, v, n);
180+
return mat3x3(u, v, n);
181181
}
182182

183183
fn rayIntersectBvh(ray: Ray, rayTMax: f32, hit: ptr<function, Intersection>) -> bool {
@@ -352,7 +352,7 @@ fn textureLookup(desc: TextureDescriptor, uv: vec2f) -> vec3f {
352352
}
353353

354354
@must_use
355-
fn rngNextInUnitHemisphere(state: ptr<function, u32>) -> vec3<f32> {
355+
fn rngNextInUnitHemisphere(state: ptr<function, u32>) -> vec3f {
356356
let r1 = rngNextFloat(state);
357357
let r2 = rngNextFloat(state);
358358

0 commit comments

Comments
 (0)