jalberse / shimmer

Physically based rendering in Rust
Apache License 2.0
33 stars 0 forks source link

Resolve non-normalized rays at start of evaluate_pixel_sample() #52

Closed jalberse closed 4 months ago

jalberse commented 5 months ago

generate_ray_differentials() normalizes the ray direction internally, but the final render_from_camera transformation can result in a non-normalized vector. In debug mode, this causes the debug_assert!() to fail which checks if the ray direction is normalized.

Now, I don't know if this impacts the final image in a meaningful way - scenarios where we strictly need the direction normalized, we should already normalize it.

Should we just normalize the direction at the end of generate_ray_differential() after the transform?

jalberse commented 5 months ago

The issue was a bug in the rotate() matrix construction; the [0][0] element added the cos value rather than multiplying by it (d'oh).

Will resolve when I merge the Killeroos branch