The point is to detect normals that are largely “up or down” compared to “sideways.”
The “Z” coordinate value can be used to test “how much up is this normalized vector.” Absolute “Z” tests “how much straight up or straight down is this normalized vector”
The “perfect value” to use for this (45 degrees off the ground plane) is Sqrt(0.5) or about 0.707. I picked 0.80 because I wanted to bias slightly towards “don’t change the basis.”
The reason the basis needs to change at all, is that if the basis is “Z” and the normal is also “close to Z” then the math degenerates and becomes unstable, or even singular (zero and division by zero) which ends up rendering poorly or not at all. You could use a value like 0.99 and still have a stable solution, if you wanted.
1 Like