karansher / computer-graphics-ray-tracing

Computer Graphics Assignment about Ray Tracing
0 stars 0 forks source link

Normalize 3d vectors in calculation #10

Open icathychen opened 2 years ago

icathychen commented 2 years ago

I was writing the Blinn-Phong shader and realized that the colour and shades significantly change when the 3dvectors are normalized when doing calculations.

I was wondering why we need to normalize all the direction vectors when doing the calculation (especially for dot product and calculating half angle ray between ray and light).

Glowies commented 2 years ago

The half-angle ray formula is just an estimation for the ray that would bisect the angle between the two vectors. This estimation is most accurate when both input vectors are normalized. To get a better intuition on why, you can try playing around with the vectors on this Geogebra app: https://www.geogebra.org/calculator/a2nadxff