Skip to content

Commit c040325

Browse files
committed
Normalize ray direction in all codepaths
1 parent f795e2d commit c040325

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/pt/raytracer.wgsl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ fn rayColor(primaryRay: Ray, rngState: ptr<function, u32>) -> vec3f {
186186
ray = Ray(p, scatter.wi);
187187
throughput *= scatter.throughput;
188188
} else {
189-
// TODO: I don't think this needs to be normalized
190-
let v = normalize(ray.direction);
189+
let v = ray.direction;
191190
let s = skyState.sunDirection;
192191

193192
let theta = acos(v.y);
@@ -210,7 +209,7 @@ fn rayColor(primaryRay: Ray, rngState: ptr<function, u32>) -> vec3f {
210209

211210
fn generateCameraRay(camera: Camera, rngState: ptr<function, u32>, u: f32, v: f32) -> Ray {
212211
let origin = camera.origin;
213-
let direction = camera.lowerLeftCorner + u * camera.horizontal + v * camera.vertical - origin;
212+
let direction = normalize(camera.lowerLeftCorner + u * camera.horizontal + v * camera.vertical - origin);
214213

215214
return Ray(origin, direction);
216215
}

0 commit comments

Comments
 (0)