

but I’ve accepted defeat in trying to understand it
I may have shared the link but even I don’t know how it how it works.
It’s like admiring the Eiffel Tower; you can understand that it’s a marvel of engineering without understanding the underlying engineering concepts. Such experiences are rare but they truly humble you.
Regarding the square root, understand the following concepts
- Bit shifting simply shift the bits to a certain side (Left or right) =>
0010 << 1 → 0100
- Mathematically, it multiplies or divides the input number with a factor of 2, depending upon the type of shift
- If you shift the number
n
with a nice shift amountx
(I have greatly greatly over-simplified this), then you can calculate the inverse sq. root since inverse square root is2^(-1/2)
- Calculating the inverse square root manually will take lots of clock cycles, which was not feasible for a FPS game with the limited h/w
- Bit shifting is a lot faster since we are not computing, but instead shifting
The resultant shifting gives us an answer which is close enough to the answer, and that is good enough for FPS games for calculation of reflections.
PS: Someone who is more experienced in this domain can correct me if I’m wrong.
Thanks for this. Got a burst of nostalgia