Just another Reddit refugee

  • 12 Posts
  • 690 Comments
Joined 2 years ago
cake
Cake day: June 11th, 2023

help-circle


  • 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

    1. Bit shifting simply shift the bits to a certain side (Left or right) => 0010 << 1 0100
    2. Mathematically, it multiplies or divides the input number with a factor of 2, depending upon the type of shift
    3. If you shift the number n with a nice shift amount x (I have greatly greatly over-simplified this), then you can calculate the inverse sq. root since inverse square root is 2^(-1/2)
    4. 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
    5. 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.

    Source for bitshifting

    PS: Someone who is more experienced in this domain can correct me if I’m wrong.