REVEALED: Quake III's SECRET Algorithm!

2024 ж. 1 Мам.
498 341 Рет қаралды

When the Quake III Arena source code was released to the world it contained a previously unknown algorithm called the Fast Inverse Square Root. This is the story of this strange algorithm and how it works as told by retired Microsoft software engineer Dave Plummer.
Thanks to viewer Brandon Pinske for the video topic suggestion!
For more info on the FISR:
A great video with better math explanations: • Fast Inverse Square Ro...
A surprisingly complete and detailed Wikipedia article: en.wikipedia.org/wiki/Fast_in...
Amazon Affiliate links for products mentioned in the video:
Zen of Code Optimization - amzn.to/2VO7ltx
Zen of Graphics Programming - amzn.to/3AxTAh9
Zen of Assembly [Out of Print] - amzn.to/2VD7Arn
Chapter Markers:
00:00 The Story
02:10 Welcome
03:25 Vectors
04:30 Normalization
05:48 Pythagoras Redux
07:50 Behold Code
09:10 Roots and Floats
10:21 Newton, Approximately
11:14 Rate of Change
13:02 C++ Code
14:15 Gates and Allen
15:04 Outtakes and Rarities
Errata: Please let me know in the comments of any important errors or omissions, and I will update things here. Currently, the only major update is at the end - I leave you with the impression that IEEE-754 might have been based on MBF, but I don't think that's the case. I will expand on this in Part 2, but recommend these two links for the curious:
• "The IEEE Standard 754: One for the History Books,"
www.computer.org/csdl/magazin...
• "An Interview with the Old Man of Floating-Point,"
people.eecs.berkeley.edu/~wkah...

Пікірлер
  • "If there's anything that Bill Gates taught me, it was never to name drop"... I laughed harder than I should've at that

    @nathanmielke1977@nathanmielke19772 жыл бұрын
    • I'm *really* hoping people took that as a joke and not a flex, but I don't know, it's pretty dry! ;-)

      @DavesGarage@DavesGarage2 жыл бұрын
    • @@DavesGarage perfect delivery

      @macaw2000@macaw20002 жыл бұрын
    • @@DavesGarage If they don't like it, they can double click the thumbs down button... LOL .. You are comic gold.

      @garisonhayne668@garisonhayne6682 жыл бұрын
    • @@DavesGarage The first time I heard it, I didn't think anything of it, but then I thought "wait a minute..." On the second playthrough, I had to pause because I was laughing too hard to pay attention. Excellent delivery. Bravo!

      @WarrenGarabrandt@WarrenGarabrandt2 жыл бұрын
    • A sublime moment.

      @sp10sn@sp10sn2 жыл бұрын
  • Greatest arena shooter of all time, I miss Quake 3 so much, occasionally I'll launch it and browse the countless empty servers that were once full and shed a tear.

    @WarriorRazor@WarriorRazor2 жыл бұрын
    • For most of this older games you can find communities that arrange matches

      @munchlax633@munchlax6332 жыл бұрын
    • There are plenty people in Europe still playing Quakelive. Come join

      @frankdux9254@frankdux92542 жыл бұрын
    • Surprisingly openarena still has active players

      @alejandrocastro211@alejandrocastro2112 жыл бұрын
    • I'd argue Unreal Tournament is better.

      @FlyboyHelosim@FlyboyHelosim2 жыл бұрын
    • Yeah quake live is where they all moved to

      @aqualili@aqualili2 жыл бұрын
  • "Abuses the compiler in ways I've never seen before." Classic!

    @michaelafcadio@michaelafcadio2 жыл бұрын
  • I’m a programmer, and I understood maybe 5% of everything Dave said. Yet I was still mesmerised by it all.

    @mikemcgrumpy@mikemcgrumpy2 жыл бұрын
    • it´s because the real magic here isn't the programming but the brilliant math behind it. I remember that back in university one of my professor's teams, worked with european university and they were doing some surface proccesing, and each run took many many hours to complete, the team was able to reduce the running time under 15 minutes, I don't remember exactly how much, but it was amazing, that with the right math, you can solve extremely complex things with waaaaaaaaaaaaaaaaaaaaaaay less code lines and computing

      @zeratul600@zeratul6002 жыл бұрын
    • That’s not ideal, you should rewatch the video, read up on these topics and try and understand. Any decent programmer should be able to understand the FISR algorithm

      @asinzuar@asinzuar2 жыл бұрын
    • @@asinzuar While I understand your point, and agree with it to a point, I have been programming for 20 years, and have built a number of commercially successful products. Not once in my entire career have I even needed to know what the acronym "FISR" stands for, let alone needed to understand the algorithm. I recognise I would never get hired by a FAANG, but I find the claim that one "should" understand this topic in order to be considered decent a bit of a stretch. I deeply admire the minds of those who do understand stuff like this though. Which is why I love watching this type of content.

      @mikemcgrumpy@mikemcgrumpy2 жыл бұрын
    • @@mikemcgrumpy I didn’t mean that every programmer should know about FISR even before watching this video. Just that (apart from the details of Newtonian iteration) it should make sense to a programmer once you read about it. I just wish people would work at understanding these things instead of giving up at 5%. However I realise my comment was a bit snarky so apologies for that.

      @asinzuar@asinzuar2 жыл бұрын
    • @@asinzuar not everyone is passionate about learning math from the ground up. I can solve higher complexity programming problems, but will get stumped on beginner ranked problems simply because it requires moderate algebra or basic calculus which I took no interest in during highschool. Not my fault the school I went to made math seem like an imagination driven, arbitrary mess of boring numbers with no real world functionality. Physics was fun despite not having any knowledge of calculus, got a trash grade because I hadn't taken calc, but they just make it so insufferable. feels like you're working towards nothing. If I knew the power of it back then as I do now, I would have taken all the math classes.

      @Aresous@Aresous2 жыл бұрын
  • I did some digging and found that Cleve Moler (MATLAB) had a hand in deriving the constant used in the algorithm. It's funny that no one knows how exactly it was derived in the first place.

    @WimukthiBandara@WimukthiBandara2 жыл бұрын
    • Just some brute force testing perhaps? Just calculate which constant outputs the best results for a set of samples

      @migueeeelet@migueeeelet2 жыл бұрын
    • @@steviesteveo1 Well, since it's representable on a graph, you could simply plot a bunch of them at the same time and visually confirm & choose the best one. Repeat a few times, with slight modifications.

      @migueeeelet@migueeeelet2 жыл бұрын
    • @@steviesteveo1 Yeah, I can see that

      @migueeeelet@migueeeelet2 жыл бұрын
    • As I understand it, one could newton a near-optimal constant pretty easily, and then maybe try several similar constants on a test set of 0.255, 0.265, ... , 0.985, 0.995 (factors of 4 won't change the quality of the algorithm; input a value of 4 times X, and you get a result that's twice the result of X). Test-running the algorithm for 75 values and computing either the sum of squares of errors or the worst relative error used to be inexpensive back then; the average load was ~1000 calls per frame. After each test, you could randomly modify the value again, each time by a smaller amount, until the improvements are insignificant (or maybe until you fail to get any improvement at all for 10 iterations in a row). That's not a trivial workload, but in the QIII age, CPUs had built-in FPUs (so the exact square root isn't exactly SLOW either), and it can be automated easily (coded in ~15 minutes and run for a few seconds). However, the most important issue is to use higher quality comments than "What the 🍆?" -- a comment confirmed by the code snippet uploaded to Wikipedia.

      @achtsekundenfurz7876@achtsekundenfurz7876 Жыл бұрын
    • I've gotten mad and drunk at a problem and wrote stuff that worked great but I dont remember what I was thinking

      @hypercube33@hypercube3311 ай бұрын
  • I have always wondered why QIII was THAT smooth back in a day when such smoothness for such quality seemed impossible still ... and now I know. Thanks, Dave :)

    @The_O@The_O2 жыл бұрын
    • Yeah! Quake 3 was stunningly smooth for how good it looked. With games like Unreal I only cared that I could get it to run smooth enough to play. With Q3 suddenly it became a fun game to tweak hardware and settings to achieve buttery smoothness and insane FPS.

      @amorasaki@amorasaki2 жыл бұрын
    • it's not because of one single coding trick that's explained in this video

      @Cenot4ph@Cenot4ph2 жыл бұрын
    • @@amorasaki mp_picnic 5 If I recall correctly, it converted everything to very primitive gpx, but added like 50 fps

      @demukazz@demukazz2 жыл бұрын
  • I am good at math, and when I first saw that algorithm, I was completely floored. Cracking good stuff Dave!

    @geoffreyanderson2285@geoffreyanderson22852 жыл бұрын
    • Thanks! I'm not a math guy so hope I didn't embarrass myself too much!

      @DavesGarage@DavesGarage2 жыл бұрын
  • That fast inverse square root is a gem of an algorithm! Also, happy birthday!

    @jelleverest@jelleverest2 жыл бұрын
    • i wonder if there are more "hidden" algorithms that will one day be found to simplify complex instructions

      @baumstamp5989@baumstamp59892 жыл бұрын
    • @@baumstamp5989 It didn‘t simplify anything. It‘s an approximation. It saved computation time at the cost of accuracy. And it‘s actually more complicated than calculating the actual square root. And by the way on modern CPUs it‘s not useful anymore.

      @NymezWoW@NymezWoW2 жыл бұрын
    • @@NymezWoW ?

      @snyggmikael@snyggmikael2 жыл бұрын
    • I guess "simplify" in this context means reducing the amount of steps to execute for the CPU (in terms of cycles). That said, these kind of algorithms have always been around, one of my favorite is CORDIC (a variant of which is used in the FPU hardware, I imagine) for approximating trigonometric functions. Obviously with the modern CPUs, these algorithms lose relevance (or delegated into the HDL space).

      @perplexedmoth@perplexedmoth Жыл бұрын
  • I have a small collection of Abrash's books and I even managed to get his Graphics Programming Black Book signed by Carmack. I had gone to Oculus Connect with the hope of getting Michael's autograph but he was never available. He is such a brilliant person, to be able to just walk down the hall and pick his brain must have been an amazing perk of working at Microsoft.

    @sryx@sryx2 жыл бұрын
    • He's of course publicly more well known than most, but there were just SO many people there that were amazing resources. From Raymond Chen to Dave Cutler, the access to experts was incredible!

      @DavesGarage@DavesGarage2 жыл бұрын
    • 1800 pages of pain

      @emmanuelbeaucage4461@emmanuelbeaucage44612 жыл бұрын
    • @@emmanuelbeaucage4461 Imagine writing it.

      @pseudocoder78@pseudocoder782 жыл бұрын
    • @@DavesGarage imagine these brilliant people getting the same attention as say a "Kardashian" 🤣

      @Thros1@Thros12 жыл бұрын
    • Having been a hobbyist C/C++ graphics coder for almost 30 years, I naturally bought the GPBB shortly after it released, and - now well-used and falling apart - it still holds pride of place in my bookshelf today. Even now, much of the fundamentals of Quake tech is at the core of my self-written, raytracing-capable 3D graphics engine, which I'm literally still refining to this day. Not because I have to, but because it's still a fun thing to work on. Abrash's commentaries on everything from basic axioms (such as 'there is no such thing as the fastest code'), to the math and magic behind the Quake engine's inner workings (surface caching, VSD/HSR via BSP, span rendering) quickly changed me from a young buck thinking there were only limited ways of getting things done, to a much wiser man who is never afraid to try any optimisation idea no matter how crazy it seems. People generally hail the likes of Gates and Carmack in the computing industry... but for me, Abrash was always the hero of the day.

      @ecarter2747@ecarter27472 жыл бұрын
  • Spoiler: it's maths.. if you raise some number to negative exponent, it's same as 1/n^m... second part of the spoiler: dividing m (the exponent) by two is same as taking a square root... think about it, 2^8 for example is 256.. square root of 256 is 16.. which is 2^4, which is (2^(8/2)) and so forth.. floats are encoded as sign * mantissa * 2^exponent, where exponent is between -126 and +127 (some values are reserved for special use like Not-a-Number, Infinity and so on..). The (i >> 1) in the code shifts exponent bits right once, which is same as dividing by two.. which is same as square root, and the subtraction does negation so is doing the reciprocal. The WTF part is the magic constant which less people would stumble on their own (yours truly included).

    @n00blamer@n00blamer2 жыл бұрын
    • thanks

      @JeffJennings82@JeffJennings822 жыл бұрын
  • This is awesome. I'm aware of the FISR and had always wondered whether anyone got some kind of answers as to its origin. Looking forward to the later episodes. This is my first time on this channel but I'll be sure to come back. Also Happy Birthday! 🎊🥳🍰

    @AdobadoFantastico@AdobadoFantastico2 жыл бұрын
  • For what it is worth: I made a hobby CPU on an FPGA (custom ISA, I call it BJX2, essentially a VLIW with variable-length bundles). Its FPU only does FADD/FSUB/FMUL in hardware, so I use algorithms fairly similar to the FISR in the video for doing things like floating point divide and square-root in general (just typically with a few more Newton-Raphson stages for sake of accuracy). Basically works, was cheaper than doing it in hardware, and was speed competitive with my original attempt at a hardware FDIV/FSQRT module. (The HW also does format conversions; FP-compare ops are handled via the integer ALU).

    @BGBTech@BGBTech2 жыл бұрын
    • @Brandon O'Connell Yeah, this sort of thing quickly turns into acronym soup... Also, this is sort of a "hard mode" project (have thrown several years at it, still unclear if it will be useful). Also wrote a C compiler for it (in parallel), and have ports of several old games (Doom, Quake, ...). Its SIMD capabilities and similar are also strong enough that it can semi-competently run software-rasterized OpenGL (it can also run GLQuake), ... Though, on the main FPGA I am using (an XC7A100T), I am limited to ~ 50MHz, and performance is quite limited by memory bandwidth (Quake is mostly limited to single-digit framerates).

      @BGBTech@BGBTech2 жыл бұрын
    • That's really cool... I've only ever done FPGAs in college! I've never done the gate logic or microcode for a division, but I've written the 6502 ASM version, and that's pretty darned close I bet!

      @DavesGarage@DavesGarage2 жыл бұрын
    • @@DavesGarage Yeah. My core doesn't use any microcode, and doesn't have a hardware integer divider either, so this is also done in software (in ASM, using the 'binary long division' algorithm). In some cases, I also use an approach based on using a lookup table of reciprocals (and multiply by fixed-point reciprocal), but this only "wins" in certain contexts (loses most of its advantage in the "general case"). Floating-point divide is a little nicer in that it turns into what is essentially a biased integer subtract followed by a few Newton-Raphson stages and some sign-bit twiddly and similar (also SIMD friendly, in premise). Note that in my case, the FPU uses GPRs, but the GPR space is relatively large (I am doing ALU, FPU, and 64/128-bit SIMD, all in a single register space; at present 64x 64-bit or 32x 128-bit; where the 128-bit registers exist as pairs of adjacent 64-bit registers). The single register space also avoids issues like needing a redundant set of memory load/store instructions, allows for some 128-bit ALU ops, ...

      @BGBTech@BGBTech2 жыл бұрын
    • Oh man, of love to do something like that myself one day, but I've got other stuff going on.

      @Bobbias@Bobbias2 жыл бұрын
    • We know we're on to something really big by the number of other people who step up to take credit for our work!

      @firetip198@firetip1982 жыл бұрын
  • Dave is like, I'm not very good at Math, then goes into a detailed breakdown of newtonian logs....Kinda lost me at this point. But watched to the end, as it is really interesting anyway. I've never considered this approach to problem solving before...I can see its value. One area where such an approach might be useful is laying out DAGs. Btw - if anyone has a decent algorithm for that based on rectangles representing nodes, let me know.

    @dpapa2175@dpapa21752 жыл бұрын
    • Check out hashgraph DAG.

      @VenturiLife@VenturiLife2 жыл бұрын
    • It pains me to say tho, that most of what he said is nothing more than basic linear algebra, and I still didn't get it.

      @tralphstreet@tralphstreet2 жыл бұрын
    • Well, that's the Dunning-Krüger effect. People that are very competent in a field tend to underestimate their skills. While incompetent, people overestimate theirs. I guess it's mainly because incompetent people lack the information about a given topic, so they underestimate the complexity of it. Just have a look at a simple old-fashioned mechanical clock, seems pretty simple at the first glance, just a few gears driving 2-3 needles. But as you open it, you might find that it is a bit more complex than the outside gives away.

      @mcgeufer@mcgeufer2 жыл бұрын
  • Michael Abrash is one of my heroes. Ever since I was a teenager reading his Zen books, I've looked up to him as some sort of wizard. It's been decades since then and his work still amazes me every time I stumble across it.

    @adamsfusion@adamsfusion2 жыл бұрын
    • I wonder if he's still in VR

      @Aggrofool@Aggrofool2 жыл бұрын
  • This is the most fun video discussing this algorithm I've seen so far. You're a great storyteller.

    @ClankioAi@ClankioAi2 жыл бұрын
  • Happy Birthday! Even though I already saw a video in which FISR was explained in detail, I had to watch your take on it. The intro was captivating. You know how to tell a story. Damn! I think I have to rewatch your stuff about task manager now.

    @definetlynotacomment1184@definetlynotacomment11842 жыл бұрын
  • Happy birthday, Dave! And thank you a lot for this excellent video!!

    @brunomazzei100@brunomazzei1002 жыл бұрын
  • Red Faction was also insane in terms of optimization. I recall playing it around 20 years ago on 300 Mhz CPU (most likely 233 Mhz real speed), 128 SDRAM and 16 MB of video memory or overall a very similar system and was amazed at how smooth it ran!

    @momchilandonov@momchilandonov2 жыл бұрын
    • Oh yeah! Red Faction was precursor of massive terrain destruction in FPS games. Three of my most favourite shooters were Q3, Red Faction and AVP2.

      @TheSzybas@TheSzybas2 жыл бұрын
    • moore's law meant that our understanding of building components outpaced our ability to fully utilizze those components and the mid 80's to the mid 2000's were the golden era of matching those two curves by the human mind alone. thats my theory anyway

      @Mrmaverickism@Mrmaverickism2 жыл бұрын
    • omg yes, red faction was doing something so unique

      @willielast@willielast2 жыл бұрын
    • Red Faction was amazing. It was my favorite shooter because it had vehicles. All my friends were diehard Quake or UT or even Tribes fans (Tribes was my second fav because of base defense). Cool to see other RF nerds talk about it like this.

      @dangerouskoin4874@dangerouskoin48742 жыл бұрын
    • The destructible terrain in Red Faction was really disappointing though, you only had to use it at most 3 or 4 times and then it's just forgotten about, and then the shooting and AI is really mediocre.

      @asddw4998@asddw4998 Жыл бұрын
  • This algorithm is impressively optimal and great for learning about cs, floats and binary. If you want a bit of a deeper dive into the math behind it I recommend the video "fast inverse square root" by Nemean. Looking forward to the next video about it!

    @arthurarg2789@arthurarg27892 жыл бұрын
    • Excellent presentation !

      @deedewald1707@deedewald17072 жыл бұрын
    • Ah! Thanks for reminding me what his name was.

      @Brahvim@Brahvim6 ай бұрын
  • Very interesting, I have been programming for 20 years and it's the first time I see code using the Math I learned in school.

    @0x6664@0x66642 жыл бұрын
  • 90% of all this goes over my head, yet I'm 100% intrigued by these videos.

    @wadz668@wadz6682 жыл бұрын
  • More like this please, LOVE numerical methods and related programming!

    @yiannos3009@yiannos30092 жыл бұрын
  • 😂nice intro Dave! besides, talking about optimizations, I was lucky enough during my uni years to have some applied maths to computers and studied functions iterative models where you decide on the precision and find the loop scheme function that gets to the precision in lower cycles. once you're a programmer and having that in mind, it changes the game!

    @hadireg@hadireg2 жыл бұрын
  • Love this channel. Thanks for taking the time and sharing these stories.

    @NolePTR@NolePTR2 жыл бұрын
  • I've gone over this code a few times, first from an old usenet post. Dave's explanation is one of the better ones I've seen, aside from the hand wavy don't worry about calculus.

    @Codeaholic1@Codeaholic12 жыл бұрын
    • Thanks!

      @DavesGarage@DavesGarage2 жыл бұрын
    • Me too. First saw it a few years ago and thought it would be pretty easy to unravel. Hah! Keep coming back to it every now and then. Totally agree that Dave is the best explainer of what it is and does.

      @soulGrafitti@soulGrafitti2 жыл бұрын
  • Happy Birthday! Be advised that many causual viewers might confuse the title with "The Dreaded Algorithm", which is KZheadr parlance for KZhead's increasingly arbitrary AI way of finding things to block, ban or demonetise videos based on a set of criteria which, by now, even they probably don't fully understand.

    @KennethSorling@KennethSorling2 жыл бұрын
    • Thanks for the tip! Now that you mention it, I bet a LOT of people are going to assume that's what I mean, now that I think about it the context of a general KZhead audience... I guess we will see!

      @DavesGarage@DavesGarage2 жыл бұрын
    • @@DavesGarage That was the first thing I thought of before seeing the channel.

      @LaZZeYT@LaZZeYT2 жыл бұрын
    • KZhead's BLOCK, BAN, & DIE (= kill) algo is based on the satanic "global" elites desire to befuddle all brains by inverting reality, directing a constant 24/7 "two mins of hate" (at whatever designated enemy du jour) and thereby enforcing a strict "criticize your masters is a capitol offense" death cult, i.e. communism....

      @vvvci@vvvci2 жыл бұрын
  • Love Nemean's video on the topic. Great to see you covering it!

    @malkster99@malkster992 жыл бұрын
  • I saw your short intro video for this and looked up the algorithm. And knew I had to wait for your explanation. And I was not disappointed. It was cool for you to explain your theory of where it might have come from even if Mike was not the source. Working around him must have been a treat. I had the opportunity to work with a guy in the early ninties when you called him for support he would debug your c/c++ code calling his library and tell you what you did Wrong over the phone without ever seeing your actual source code. Blew my mind. Turns out the guys first career was in theoretical physics.

    @quincy1048@quincy10482 жыл бұрын
  • Happy Birthday Sir🎉, That was quite a cliffhanger.😆

    @harshgandhi100@harshgandhi1002 жыл бұрын
  • I just got back into working on graphics for my game - I wish I would have watched your video as a refresher on vectors instead of pulling out a graphics math book. This was great!

    @mezzanine510@mezzanine5102 жыл бұрын
  • Happy Birthday :D Really been enjoying your content. Keep at it!

    @stoef@stoef2 жыл бұрын
  • I read Michael's Zen of Graphics Programming when I was a school kid back in the 90's. I was truly fascinated by those algorithms and the way Michael optimized the code step by step, first in C and then in assembly. Those were the golden years.

    @KirillGorelov81@KirillGorelov812 жыл бұрын
  • have watched this video 3 times now, it just speaks to me! Q3A was so far ahead of its time in terms of graphical quality and performance, love it!

    @Jackarius86@Jackarius862 жыл бұрын
  • I remember reading a write up explaining (or trying to explain) how this algorithm worked shortly after the source code was released. While I didn't get it, it was a fascinating algorithm.

    @Karreth@Karreth2 жыл бұрын
  • Happy Birthday. Love all the great content, one of my favorite channels.

    @rnbiii@rnbiii2 жыл бұрын
  • Happy birthday! This is the second video I've seen about this algorithm, but I am enjoying your video much more. Cheers!

    @TheSilent333@TheSilent3332 жыл бұрын
    • Awesome! Thank you!

      @DavesGarage@DavesGarage2 жыл бұрын
  • The 3D wireframe vector graphics in the 80's games Mercenary & Elite, made me into a hardcore maths junkie from the age of 14. It stimulated my passion for maths, by wanting to know & learn how to do it myself & improve on it. So watching that talk-through was great, understandable & clearly presented. Maths got me into coding 3D vector graphics & also texture-map routines on the C64, Amiga & PC for major games companies.l during the late 80 & early 90's. Still loving mathematics - coding OpenGL, Vulcan & DirectX to this day. As well as many DSP routines on microcontrollers... - HAPPY BIRTHDAY, feller. ENJOY! ✌🏽😎

    @PemboPemberton@PemboPemberton2 жыл бұрын
  • I wrote a solution to a problem in a math exam that no one else could solve, and the "show your work" part as a basic program source code for my Texas Instruments 82. My math-teacher gave me a fail on the question, but was later overruled as the TI-82 was an allowed tool on the exam :)

    @incubuz1980@incubuz19802 жыл бұрын
    • Awesome! If it was an allowed device and you solved it, I call that a win!

      @DavesGarage@DavesGarage2 жыл бұрын
    • @@DavesGarage&& @incubuz1980 TI BASIC!

      @angrybirds2472@angrybirds24726 күн бұрын
  • Happy Birthday Dave! Thank you for sharing all this, it’s always fascinating!

    @marcosgazamanes6165@marcosgazamanes61652 жыл бұрын
  • That's a great video Dave. Really enjoyed it. I used Newtons method so much in my degree. The one bit of the video I felt genuinely confident about understanding!

    @PaulMJohnson@PaulMJohnson2 жыл бұрын
  • Thanks for these videos, Dave! They're great!

    @HeavyD6600@HeavyD66002 жыл бұрын
    • Glad you like them!

      @DavesGarage@DavesGarage2 жыл бұрын
  • I've recently started to take programming a lot more seriously and i've really been enjoying the challenge of c++, your channel is exactly what I was looking for, thank you

    @MrBmxerFTW@MrBmxerFTW2 жыл бұрын
    • C is no serious language though ;) rather an ugly 70s hack of the English BCPL, where they replaced the normal =, *and, or* with silly ==, &&, | |. C++ is basically just C with classes (that the Dane Bjarne Stroustrup took from the Norwegian 1960s language Simula).

      @herrbonk3635@herrbonk36352 жыл бұрын
  • learning CNC machining, I struggled so hard and now after being done with that a while, hearing the Vector speach really brings position into perspective when it comes to learning how to sequence tool paths, to physical positioning of said material in the machine pegged on that table. How neat

    @xxIONBOMBxx@xxIONBOMBxx Жыл бұрын
  • These videos strike a wonderful balance between enough verbosity to satisfy my curiosity, and enough handholding to walk me through new concepts Ty Dave, very cool

    @beahydrated@beahydrated2 жыл бұрын
  • Proving that, in general, close enough is good enough.

    @UncleKennysPlace@UncleKennysPlace2 жыл бұрын
    • Within 1 percent !

      @deedewald1707@deedewald17072 жыл бұрын
    • It just works!

      @zachariahtrench7863@zachariahtrench78632 жыл бұрын
  • Talking about Newton's method at 10:40 for finding square roots took me back to my high school calculus class around 1982. My math teacher was just a great guy and a great teacher but I remember thinking how odd it was to "start with a guess". I can see him standing in front of the chalkboard, going through the entire process by hand. I remember thinking that just couldn't be right. It seemed just so un math-like. But, here we are.

    @shawno66@shawno662 жыл бұрын
  • Happy birthday, Dave thanks for your terrific posts!

    @chuckobra@chuckobra2 жыл бұрын
  • Happy Belated Birthday Dave! As a non-programmer your channel as well as Modern Vintage Gamer are 2 of my favorite channels. I know it's your birthday but I'm going to buy myself a gift. A Dave's Garage mug.

    @Gummibri@Gummibri2 жыл бұрын
  • Enjoyed the intro build up, set the stage very well... especially the name dropping lol Happy Bday!

    @Komeuppance@Komeuppance2 жыл бұрын
    • Thank you! 😁. I hope everyone gets that was a joke!

      @DavesGarage@DavesGarage2 жыл бұрын
    • @@DavesGarage It did take me a minute to get it. But it made me chuckle for an unreasonble amount of time when it clicked

      @Deemo_codes@Deemo_codes2 жыл бұрын
    • @@DavesGarage delivery was excellent, just my kind of humor that makes people pause, "Wait... what did he just say?" Also, your story of meeting Bill Gates, and correcting him, legitimizes the joke lol

      @Komeuppance@Komeuppance2 жыл бұрын
  • Perfect ending !! i was wondering why it was too short, he got me

    @juanma9511@juanma95112 жыл бұрын
  • You tease.... good stuff so far, brings back memories of coding in cad display drivers in assembly...

    @ToBeeOrNotToBeHoney@ToBeeOrNotToBeHoney2 жыл бұрын
  • Man this has got to be the only time I've subscribed based solely off an intro. Excellent storytelling!

    @deus_ex_machina_@deus_ex_machina_2 жыл бұрын
  • I think anyone that understands the floating point format can get there head around this algorithm. Creating it on the other hand.....

    @lucidmoses@lucidmoses2 жыл бұрын
    • It just takes some math fanatic who knew there is a certain power of 2 (2^128 iirc) that you can use for technomancer level bit manipulation

      @BlastinRope@BlastinRope2 жыл бұрын
  • I've worked in InfoSec, specifically Incident Response, for nearly 10 years. Our team and teams like ours respond to clients when threat actors have broken into their network and caused problems (which is an understatement). A common example are ransomware cases. Throughout my entire IT tenure, I've commented on how I've never needed much math. I went up through Calc 2, maybe higher, I don't even remember. I read/write C/C++ and various scripting languages often. And yet I never really need anything more than modulus. Every once in a while, I remember that game programming is a different animal. This video has *proven* that to me! I'm going to share this with all my cohorts. We all think we're sooooo special... let's see how many of us can actually following along with this video :).

    @rj_chap@rj_chap2 жыл бұрын
  • Besides the massive knowledge dumps (mind blown), I love the end reel bloopers.

    @dsuess@dsuess2 жыл бұрын
  • Happy birthday and what a wonderful video, I've been hammering out code to solve some 3d world coordinate conversion from AI cameras (without frameworks), this has helped me understand what I'm doing and I'm please to say I can now convert coordinates back to 2d accurately enough. Your outtakes were fun too, if I'd recorded my outtakes in coding on this project it would be a 3 month long video!!

    @74Gee@74Gee9 ай бұрын
  • That moment when you understand just enough to look at that equation and go: That's some tomfoolery right there. It's brilliant.

    @DFX2KX@DFX2KX2 жыл бұрын
  • I've always found this story fascinating. The mysterious fast inverse square function in the Q3 code. Stuff of movies I tell you!

    @xniyana9956@xniyana99562 жыл бұрын
  • Dunno how I stumbled across your channel, but this was interesting and as a bonus, you have a really pleasant voice! Keep it up :)

    @nyanray@nyanray2 жыл бұрын
  • I can't wait for part 2. What a captivating story!

    @matthewpalermo4957@matthewpalermo49572 жыл бұрын
  • "... a double thumbs-down." Hee hee. I see what you did there.

    @KennethSorling@KennethSorling2 жыл бұрын
    • You even could quadruple thumbs down for better effect! :-)

      @igorthelight@igorthelight2 жыл бұрын
    • I gave him a double thumbs down and a thumbs up too. That'll teach him!

      @taiga1295@taiga12952 жыл бұрын
    • @@taiga1295 Good Good Very Good !

      @deedewald1707@deedewald17072 жыл бұрын
  • This Algorithm is what game making is about, achieveing levels of speed that are almost indistinguishable from magic.

    @DanielLopez-up6os@DanielLopez-up6os2 жыл бұрын
    • That's what game making used to be about, now it's about rushing the product to market and cashing in on early access buyers and selling overpriced lootboxes. Who needs optimization? Just ship your 150GB game.

      @Agret@Agret2 жыл бұрын
  • Thanks David. Love your story’s and explanation of random computer stuff.

    @Bonno460xvr@Bonno460xvr2 жыл бұрын
  • i 100% appreciate the bit at the end where you directly address my thoughts as i was having them - "have you had that feeling yet? the one that says 'oh no, there's no way, he can't wrap this up in time" had me almost spit out my drink all over my laptop.

    @alefnull@alefnull2 жыл бұрын
  • I remember getting Q3A when it came out and being in the Beta. It was definitely SUSPICIOUSLY fast.

    @Real28@Real282 жыл бұрын
    • I don't remember it being any faster than other games on the market at the time, personally. My very outdated P166MMX + Voodoo2 could handle Unreal Tournament (released within a month of Q3) with playable framerates, meanwhile I was getting single digit fps numbers in Q3 on small cramped maps, with everything set to low, and 0 bots. The game was so demanding that it was played almost exclusively with r_picmip 7 in cyber cafes at the time, which completely nuked any texture detail, but increased performance, and that was on much more powerful hardware than mine. You couldn't really get playable framerates in Q3 without at least a PII 300+mhz and a Riva TNT2, and even then we're looking more at a 30fps target @800x600 and mid settings.

      @piobu5357@piobu53572 жыл бұрын
    • Everyone struggled to get Q3 to run fast when it came out. People have false memories about it. It let you turn graphics far more down then other games, still you needed a good machine to run it with decent FPS. It was just played for such long times, that everyone remembers to run it with 125fps. On release noone played anything close to like that. Everyone struggled like with every other new game. It would not run on potatoes.

      @felicksos160@felicksos1602 жыл бұрын
  • I personally think that the FISR algorithm that is present in Quake III Arena, is also present in Quake II and original Quake I. Those two games however do not have an open source code, id Software never released a source code for these two games. The reason why it is refered to as "the Quake 3 FISR algorithm" is because Quake III Arena was the only game of the series which source code has been released under GPL licence.

    @CZghost@CZghost2 жыл бұрын
    • I remember going onto the id software ftp, and finding the quake 1 source, then compiling it and running quake. It's actually slightly newer than any official release.

      @theresnobodyhere5474@theresnobodyhere54742 жыл бұрын
    • The Quake engine source code was released under GPL on December 21, 1999 and is the basis of a great many source ports. Quake II source was released under GPL on December 22, 2001. Last time I checked (some years ago), I found nothing resembling the FISR in either codebases. Quake III Arena source was released under GPL on August 19, 2005.

      @GarrettInShadows@GarrettInShadows2 жыл бұрын
  • just recently watched another video about this algorithm with a colleague and now u made one too. it's still fascinating and a true gem, probably forever. It would be really fun to see if someone was able to convert this code into such verbose code that anyone could understand it. probably a very hard challenge

    @GuRuGeorge03@GuRuGeorge032 жыл бұрын
  • MBF and IEEE754 are not same (different bit order). By the way second one was "invented" by Canadian scientist William Kahan (used by Intel in early 1970 in coprocessors before it was standard as IEEE754 much later).

    @mrlazda@mrlazda2 жыл бұрын
    • I agree, not the same. Also differnt bias in the exponent I believe. What I should have said, and what I do say in the next part, is that IEEE-754 was the standardized replacement for MBF, *not* that MBF was standardized into IEEE-754... I never said that, but I might have given that impression in the rush to wrap up the end of the first episode! I will correct those ambiguities in Part 2, thanks for bringit it to my attention!

      @DavesGarage@DavesGarage2 жыл бұрын
    • @@DavesGarage Come on, that was not an ambiguity. What you said was said very clearly and it was just as clearly wrong.

      @peterfireflylund@peterfireflylund2 жыл бұрын
  • Still playing Quake III Arena nearly daily. Yes still, after 22 years. Your Bday? Congrats!

    @paulmichaelfreedman8334@paulmichaelfreedman83342 жыл бұрын
    • Wow, I wasn't sure if folks still play it but that's cool!

      @DavesGarage@DavesGarage2 жыл бұрын
    • @@DavesGarage Not a whole lot of servers around anymore, but a few is enough :D

      @paulmichaelfreedman8334@paulmichaelfreedman83342 жыл бұрын
    • @@DavesGarage Same with the OG Unreal Tournament. I decided to load it up a few months ago and was shocked there was still a lot of servers out there and people playing it. I still suck bad at both UT and Q, but still have fun!

      @lobotomizedjellyfish2171@lobotomizedjellyfish21712 жыл бұрын
    • @@lobotomizedjellyfish2171 yep UT99 is still alive, but u will probably end on a server full of chads, who will 360 headshot you midair ; D

      @quadro1337@quadro133710 ай бұрын
  • Happy Birthday! Really enjoy the channel!

    @jasonr1199@jasonr11992 жыл бұрын
  • Love this, when I was releasing q3Ownerz and Q3FU as a kid back in the day, I would find pieces of gold in the logic like this. Black boxes in the system that when analyzed had risk. This kind of history is very nostalgic! Thanks for the video.

    @InfernalOd1n@InfernalOd1n2 жыл бұрын
  • Though my programming ability is only BASIC, sounds quiet fun to see the code.

    @johnsonlam@johnsonlam2 жыл бұрын
  • "Give it the old double thumbs down" I found this way more funnier than it probably was.

    @Mattski_83@Mattski_832 жыл бұрын
  • This is a great video and cannot wait for part 2! I got confused at 13:11 because the derivative of sqrt(X) is not a half of the old value (the "put it in another way"). It clicked for me when I realized that to solve sqrt we can actually transform the problem. If y = sqrt(x) --> y² = x. Finding the zero of the latter function with Newton's method results in the formula you used :)

    @nicolabombace2004@nicolabombace20042 жыл бұрын
  • I love the explanation of Rate of Change - so well done! When you visualise it, then it's quite lovely - and amazing for the time!

    @Rasterizing@Rasterizing7 ай бұрын
  • The FISR is another proof of what an absolute unit of a programmer John Carmack is.

    @jonasglanshed@jonasglanshed2 жыл бұрын
  • The algorithm - You point an int at a float, push some bits around, take the magic number out and Newton as a round, and that's what it's all about. Oh the coding hookey pokey. :). I find the best innervation comes when your pushed to optimise due to hardware limitations, all too easy today to add another core etc and be lazy.

    @paulgray1318@paulgray13182 жыл бұрын
    • I think that with limitations, comes the creativity (to overcome them) It is pretty nice to see limitations as challanges sometimes.

      @Ferdam@Ferdam2 жыл бұрын
  • A video about coding. And about Quake. And Math. AND there is a second part! It doesn't get much better than that. :) Thank you and Happy Birthday!

    @reeboothemad5514@reeboothemad55142 жыл бұрын
  • Happy birthday! My favourite part of the code is where they comment out the second refinement lol. Some people miss the important part of this where negative normal magnitudes are essentially meaningless in this application, which is why they completely skip the sign.

    @microcolonel@microcolonel2 жыл бұрын
  • This algo is a rock! Thanks for such a pleasant presentation!

    @dimasveliz6745@dimasveliz67452 жыл бұрын
  • Happy Birthday, Dave!! 🎉🎊

    @gertselis@gertselis2 жыл бұрын
  • It's my birthday too! Happy Birthday Dave! What a leg end!

    @DerogativePeanut@DerogativePeanut2 жыл бұрын
  • When I was in trig and Calc and such in high school I also created a program on my Ti80 or whatever the graphing calculators were back around 1996-2000. On the first test for quadratic equations my teacher was impressed that I understood it well enough and was able to make the program that he let me use it on that one test.

    @robertmurphy2794@robertmurphy27948 ай бұрын
  • Yay! You did it (and Happy Birthday as well) :-)

    @cr6925@cr69252 жыл бұрын
  • Super cool content! Stumbled on this while actually playing Quake and having Visual Studio Code open lol. New sub from me dude!

    @louis-philip@louis-philip2 жыл бұрын
  • I know this is a 2 year old video, and I am about to watch part 2 here shortly, but... You sir, have helped me understand more about ALL of this in this single video than I understood in my previous 40 years of life, total. Thank you for that. See, I struggle with different forms of math as a consequence of Spina Bifida. And in this one video you helped me understand things better than any previous teacher of mine. I am watching part 2 as soon as I finish the outtakes. :)

    @Carstuff111@Carstuff1118 ай бұрын
  • Hope for the next part soon!

    @oliver24x@oliver24x2 жыл бұрын
  • Congratulations Dave! 🎉

    @erwinheitzman9854@erwinheitzman98542 жыл бұрын
  • Great video Dave My C++ is very weak but the math was incredible that it worked way back then.

    @jeremiahlyleseditor437@jeremiahlyleseditor4372 жыл бұрын
  • This algorithm always reminded me of ramanujan's equations. He was an indian, maths prodogy who'd come up with these amazingly accurate (but still only approximate) equations with crazy constants that he'd never explain....they just worked, and that was good enough for him.

    @tomcombe4813@tomcombe48132 жыл бұрын
  • Happy Birthday! August 11 was my brother's birthday. he woulda been 38 this year :) thank you for your hard work on these videos. they are always well written and excellent presentation!

    @jamesgann560@jamesgann5602 жыл бұрын
  • I think you said that MS binary format became IEEE 754. I have worked on floats in assembler for decades, and seem to recall the MS floats were NOT IEEE 754. You also mentioned that you worked on machines that lacked some basic arithmetic operations. I had similar experiences. I had to write multiplication code for one CPU, and taking a square root was an early project when the IBM PC was brand new. Those were fun days! You learned so much.

    @preciselyvague2912@preciselyvague29122 жыл бұрын
  • Ah this is a marvel of Engineering that comes back to me every once in a while. Thanks for making a long discriptive Video about what i painfully dwelled through a few years ago. I still dont claim to have understood it. But its beautiful nonetheless. Whenever the conversation about "There is no Art in Coding" pops up, i pull out this brilliant piece of engineering. Just Art.

    @steveschwartz2814@steveschwartz28142 жыл бұрын
  • Loved the "Vector" drop. First thing I thought of when he mentioned it

    @jamesarber904@jamesarber9042 жыл бұрын
  • I can tell that most of the people gathered here really enjoy programming and the challenges that come with it. It takes a certain willingness to torture oneself and a willingness to learn constantly. People should really watch videos like this before they decide to go into game/game engine development or other math heavy concepts like machine learning. They need to understand what they might be getting into before they commit to paying for CS college classes. The same goes for any programming really... it can be a brain twisting journey sometimes. It's always great to have people like Dave who are willing to share their amazing experience with us.

    @joshman1019@joshman10192 жыл бұрын
  • Happy Birthday, Dave!

    @TrevorDBrown@TrevorDBrown2 жыл бұрын
  • Congrats 🎉🎉🎉 Keep up the great work.

    @volppe01@volppe012 жыл бұрын
  • Quality channel, thanks for the content!

    @TummyTimeTimmy@TummyTimeTimmy2 жыл бұрын
  • Happy Birthday Dave!!!

    @tnick8201@tnick82012 жыл бұрын
  • as a non-math programmer, I love the idea that (essentially) a loop that progressively gets closer to blowout is the fastest way to do a hard function. also, excellent instruction on how vector maths works with some code

    @dvandamme00@dvandamme002 жыл бұрын
KZhead