@klaus said in Fast Inverse Square Root approximation from Quake III engine:
@axtremus said in Fast Inverse Square Root approximation from Quake III engine:
That pretty much comes down to the business model.
Only after a careful analysis of the performance relevance, and a consideration of all alternatives, can it ever be justified to write code like that.
Business considerations determine which aspects of the system's performance are prized. The planes and rockets business prioritize different aspects of the system than the gaming business.
It's not like the Quake III engine's developer team did this sort of "unusual" coding all over the place. This inverse square root function garnered extra attention in large part because it's an outlier compared to the rest of the code base. The video called out why this is justified -- because the inverse square root function is used to calculate light reflection off every polygon surface in 3D-space -- considering a game can cycle through millions of polygons per second and this "unusual" implementation gets the inverse square root approximation "three times faster" than the standard sqrt() function, it seems sufficiently justified.
There is no shortage of "cowboy" software coders who like to write "unnecessarily clever" code, but there are also real resource and time constraints that strongly incentivize professional software shops to reuse code rather than write new code. "Student projects" and "hobbyist projects" aside, mentally reviewing professional software shops I have come into contact with over the years, I really cannot recall seeing "overly clever" coding being anything but generally discouraged, and have no reason to suspect the Quake team operated differently in this regard.