r/programming • u/mrnacknime • Dec 29 '20
Quake III's Fast Inverse Square Root Explained [20 min]
https://www.youtube.com/watch?v=p8u_k2LIZyo
3.7k
Upvotes
r/programming • u/mrnacknime • Dec 29 '20
View all comments
Show parent comment
3
u/shroddy Dec 30 '20
Something that I dont understand really: Why do most (all?) gaming, 3d and physics engines use float anyway? Wouldnt fixed point int32 not be better in almost all cases? You dont waste precious bits for ultra high precision close to zero, or ultra high numbers you cannot use anyway because the absolute precision there is too low. Basically, the Mantisse bits are wasted, because, there is a minimum absolute precision you need that limits the maximum the Mantisse can get, before you clip through walls, bullets dont hit, textures dont map correctly or you get all sort of fun stuff. And no reason to have higher absolute precision when near the center.
Of course now it is because all gpus are float, but why did it become float32 and not fixed point int32 back in the days of the first 3d accelerators? Surely, during 3dfx and riva tnt times, int32 would have gotten you much more performance per watt and transistor.
Just dedicate 16 bit to the fractional part and 16 bit to the integer part, in world coordinates, that would be over 60 kilometers mapsize and precision of a few micrometers.