Тёмный

REVEALED: Quake III's SECRET Algorithm! 

Dave's Garage
Подписаться 806 тыс.
Просмотров 507 тыс.
50% 1

Опубликовано:

 

11 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 963   
@nathanmielke1977
@nathanmielke1977 3 года назад
"If there's anything that Bill Gates taught me, it was never to name drop"... I laughed harder than I should've at that
@DavesGarage
@DavesGarage 3 года назад
I'm *really* hoping people took that as a joke and not a flex, but I don't know, it's pretty dry! ;-)
@macaw2000
@macaw2000 3 года назад
@@DavesGarage perfect delivery
@garisonhayne668
@garisonhayne668 3 года назад
@@DavesGarage If they don't like it, they can double click the thumbs down button... LOL .. You are comic gold.
@WarrenGarabrandt
@WarrenGarabrandt 3 года назад
@@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!
@sp10sn
@sp10sn 3 года назад
A sublime moment.
@WarriorRazor
@WarriorRazor 3 года назад
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.
@munchlax633
@munchlax633 3 года назад
For most of this older games you can find communities that arrange matches
@frankdux9254
@frankdux9254 3 года назад
There are plenty people in Europe still playing Quakelive. Come join
@alejandrocastro211
@alejandrocastro211 3 года назад
Surprisingly openarena still has active players
@FlyboyHelosim
@FlyboyHelosim 3 года назад
I'd argue Unreal Tournament is better.
@aqualili
@aqualili 3 года назад
Yeah quake live is where they all moved to
@michaelafcadio
@michaelafcadio 3 года назад
"Abuses the compiler in ways I've never seen before." Classic!
@WimukthiBandara
@WimukthiBandara 3 года назад
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.
@migueeeelet
@migueeeelet 2 года назад
Just some brute force testing perhaps? Just calculate which constant outputs the best results for a set of samples
@migueeeelet
@migueeeelet 2 года назад
@@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
@migueeeelet 2 года назад
@@steviesteveo1 Yeah, I can see that
@achtsekundenfurz7876
@achtsekundenfurz7876 2 года назад
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.
@hypercube33
@hypercube33 Год назад
I've gotten mad and drunk at a problem and wrote stuff that worked great but I dont remember what I was thinking
@sryx
@sryx 3 года назад
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.
@DavesGarage
@DavesGarage 3 года назад
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!
@emmanuelbeaucage4461
@emmanuelbeaucage4461 3 года назад
1800 pages of pain
@pseudocoder78
@pseudocoder78 3 года назад
@@emmanuelbeaucage4461 Imagine writing it.
@Thros1
@Thros1 3 года назад
@@DavesGarage imagine these brilliant people getting the same attention as say a "Kardashian" 🤣
@ecarter2747
@ecarter2747 3 года назад
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.
@The_O
@The_O 3 года назад
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 :)
@amorasaki
@amorasaki 3 года назад
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.
@Cenot4ph
@Cenot4ph 3 года назад
it's not because of one single coding trick that's explained in this video
@demukazz
@demukazz 2 года назад
@@amorasaki mp_picnic 5 If I recall correctly, it converted everything to very primitive gpx, but added like 50 fps
@geoffreyanderson2285
@geoffreyanderson2285 3 года назад
I am good at math, and when I first saw that algorithm, I was completely floored. Cracking good stuff Dave!
@DavesGarage
@DavesGarage 3 года назад
Thanks! I'm not a math guy so hope I didn't embarrass myself too much!
@n00blamer
@n00blamer 3 года назад
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).
@JeffJennings82
@JeffJennings82 3 года назад
thanks
@BGBTech
@BGBTech 3 года назад
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
@BGBTech 3 года назад
@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).
@DavesGarage
@DavesGarage 3 года назад
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!
@BGBTech
@BGBTech 3 года назад
@@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, ...
@Bobbias
@Bobbias 3 года назад
Oh man, of love to do something like that myself one day, but I've got other stuff going on.
@firetip198
@firetip198 3 года назад
We know we're on to something really big by the number of other people who step up to take credit for our work!
@jelleverest
@jelleverest 3 года назад
That fast inverse square root is a gem of an algorithm! Also, happy birthday!
@baumstamp5989
@baumstamp5989 3 года назад
i wonder if there are more "hidden" algorithms that will one day be found to simplify complex instructions
@NymezWoW
@NymezWoW 3 года назад
@@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.
@snyggmikael
@snyggmikael 2 года назад
@@NymezWoW ?
@perplexedmoth
@perplexedmoth 2 года назад
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).
@adamsfusion
@adamsfusion 3 года назад
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.
@Aggrofool
@Aggrofool 3 года назад
I wonder if he's still in VR
@mikemcgrumpy
@mikemcgrumpy 3 года назад
I’m a programmer, and I understood maybe 5% of everything Dave said. Yet I was still mesmerised by it all.
@zeratul600
@zeratul600 3 года назад
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
@asinzuar
@asinzuar 3 года назад
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
@mikemcgrumpy
@mikemcgrumpy 3 года назад
@@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.
@asinzuar
@asinzuar 3 года назад
@@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.
@Aresous
@Aresous 3 года назад
@@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.
@dpapa2175
@dpapa2175 3 года назад
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.
@VenturiLife
@VenturiLife 3 года назад
Check out hashgraph DAG.
@tralphstreet
@tralphstreet 2 года назад
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.
@mcgeufer
@mcgeufer 2 года назад
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.
@arthurarg2789
@arthurarg2789 3 года назад
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!
@deedewald1707
@deedewald1707 3 года назад
Excellent presentation !
@Brahvim
@Brahvim 11 месяцев назад
Ah! Thanks for reminding me what his name was.
@momchilandonov
@momchilandonov 3 года назад
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!
@TheSzybas
@TheSzybas 2 года назад
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.
@Mrmaverickism
@Mrmaverickism 2 года назад
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
@willielast
@willielast 2 года назад
omg yes, red faction was doing something so unique
@dangerouskoin4874
@dangerouskoin4874 2 года назад
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.
@asddw4998
@asddw4998 2 года назад
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.
@rj_chap
@rj_chap 3 года назад
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 :).
@Codeaholic1
@Codeaholic1 3 года назад
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.
@DavesGarage
@DavesGarage 3 года назад
Thanks!
@soulGrafitti
@soulGrafitti 3 года назад
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.
@AdobadoFantastico
@AdobadoFantastico 3 года назад
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! 🎊🥳🍰
@0x6664
@0x6664 3 года назад
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.
@KennethSorling
@KennethSorling 3 года назад
Happy Birthday! Be advised that many causual viewers might confuse the title with "The Dreaded Algorithm", which is RU-vidr parlance for RU-vid'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.
@DavesGarage
@DavesGarage 3 года назад
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 RU-vid audience... I guess we will see!
@LaZZeYT
@LaZZeYT 3 года назад
@@DavesGarage That was the first thing I thought of before seeing the channel.
@vvvci
@vvvci 2 года назад
RU-vid'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....
@hadireg
@hadireg 3 года назад
😂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!
@wadz668
@wadz668 3 года назад
90% of all this goes over my head, yet I'm 100% intrigued by these videos.
@Jackarius86
@Jackarius86 3 года назад
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!
@Clank-j6w
@Clank-j6w 3 года назад
This is the most fun video discussing this algorithm I've seen so far. You're a great storyteller.
@PemboPemberton
@PemboPemberton 3 года назад
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! ✌🏽😎
@KirillGorelov81
@KirillGorelov81 3 года назад
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.
@brunomazzei100
@brunomazzei100 3 года назад
Happy birthday, Dave! And thank you a lot for this excellent video!!
@definetlynotacomment1184
@definetlynotacomment1184 3 года назад
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.
@shawno66
@shawno66 3 года назад
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.
@quincy1048
@quincy1048 3 года назад
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.
@Karreth
@Karreth 3 года назад
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.
@Komeuppance
@Komeuppance 3 года назад
Enjoyed the intro build up, set the stage very well... especially the name dropping lol Happy Bday!
@DavesGarage
@DavesGarage 3 года назад
Thank you! 😁. I hope everyone gets that was a joke!
@Deemo_codes
@Deemo_codes 3 года назад
@@DavesGarage It did take me a minute to get it. But it made me chuckle for an unreasonble amount of time when it clicked
@Komeuppance
@Komeuppance 3 года назад
@@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
@yiannos3009
@yiannos3009 3 года назад
More like this please, LOVE numerical methods and related programming!
@mezzanine510
@mezzanine510 3 года назад
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!
@incubuz1980
@incubuz1980 3 года назад
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 :)
@DavesGarage
@DavesGarage 3 года назад
Awesome! If it was an allowed device and you solved it, I call that a win!
@angrybirds2472
@angrybirds2472 4 месяца назад
@@DavesGarage&& @incubuz1980 TI BASIC!
@preciselyvague2912
@preciselyvague2912 2 года назад
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.
@MrBmxerFTW
@MrBmxerFTW 3 года назад
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
@herrbonk3635
@herrbonk3635 2 года назад
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).
@tomcombe4813
@tomcombe4813 2 года назад
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.
@lucidmoses
@lucidmoses 3 года назад
I think anyone that understands the floating point format can get there head around this algorithm. Creating it on the other hand.....
@BlastinRope
@BlastinRope 3 года назад
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
@Gummibri
@Gummibri 3 года назад
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.
@DFX2KX
@DFX2KX 3 года назад
That moment when you understand just enough to look at that equation and go: That's some tomfoolery right there. It's brilliant.
@xxIONBOMBxx
@xxIONBOMBxx 2 года назад
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
@xniyana9956
@xniyana9956 3 года назад
I've always found this story fascinating. The mysterious fast inverse square function in the Q3 code. Stuff of movies I tell you!
@rjonboy7608
@rjonboy7608 2 года назад
Your story reminds me of 1979 when I was in Junior High School and my "Santa Claws" found me a Texas Instruments TI-99 4A computer instead of the Trash 80 I wanted. It was cheap enough that it "came" with 9 cartridges. 6 games, a typing tutor, an Advanced Basic, and Assembly Language. Some other family had it for awhile but I didn't care. First program I wrote was a bat and ball thing that became ping pong and tennis and brick breaking and all sorts of variations. Had to record them on cassette tapes because floppy drives cost more than the whole kit and kept getting interrupted because my brother wanted to watch shows on the TV because there wasn't a monitor. By summer I had that puppy doing everything but making breakfast. Using Assembly I could access hardware directly like you were describing about accessing pixel vectors on the raster lines which greatly improved both graphics and frames. Too bad they didn't release a TI 1982 model cross with the 286 and the NES architecture.
@UncleKennysPlace
@UncleKennysPlace 3 года назад
Proving that, in general, close enough is good enough.
@deedewald1707
@deedewald1707 3 года назад
Within 1 percent !
@zachariahtrench7863
@zachariahtrench7863 3 года назад
It just works!
@endermwatts
@endermwatts Год назад
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.
@harshgandhi100
@harshgandhi100 3 года назад
Happy Birthday Sir🎉, That was quite a cliffhanger.😆
@BlackHoleForge
@BlackHoleForge Год назад
Hearing you talk about Newtonian approximation reminds me a lot about learning about sorting algorithms. How you make a guess, and then it reiterated to get a little closer, and a little closer, until it's just right.
@CZghost
@CZghost 3 года назад
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.
@theresnobodyhere5474
@theresnobodyhere5474 3 года назад
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.
@GarrettInShadows
@GarrettInShadows 3 года назад
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.
@alefnull
@alefnull 3 года назад
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.
@mrlazda
@mrlazda 3 года назад
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).
@DavesGarage
@DavesGarage 3 года назад
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!
@peterfireflylund
@peterfireflylund 3 года назад
@@DavesGarage Come on, that was not an ambiguity. What you said was said very clearly and it was just as clearly wrong.
@Maadhawk
@Maadhawk 2 года назад
I got to meet John Carmack at one of Id's Quakecon's back in the early 2010s. Guy's brilliance was just overwhelming.
@juanma9511
@juanma9511 3 года назад
Perfect ending !! i was wondering why it was too short, he got me
@Carstuff111
@Carstuff111 Год назад
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. :)
@johnsonlam
@johnsonlam 3 года назад
Though my programming ability is only BASIC, sounds quiet fun to see the code.
@Quaker763
@Quaker763 3 года назад
A note on the history here. This algorithm goes back as far as Gary Tarolli (of 3Dfx fame) while he was working at SGI. He says he got it off someone else, so it must've been floating (pun intended) around between graphics programmers at the time.
@DanielLopez-up6os
@DanielLopez-up6os 3 года назад
This Algorithm is what game making is about, achieveing levels of speed that are almost indistinguishable from magic.
@Agret
@Agret 3 года назад
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.
@joshman1019
@joshman1019 3 года назад
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.
@KennethSorling
@KennethSorling 3 года назад
"... a double thumbs-down." Hee hee. I see what you did there.
@igorthelight
@igorthelight 3 года назад
You even could quadruple thumbs down for better effect! :-)
@taiga1295
@taiga1295 3 года назад
I gave him a double thumbs down and a thumbs up too. That'll teach him!
@deedewald1707
@deedewald1707 3 года назад
@@taiga1295 Good Good Very Good !
@billybollockhead5628
@billybollockhead5628 Год назад
The number of times I tried to teach vector math/normalization to students - and I always failed to get the entire room to understand it, I couldnt figure out a good way to keep it simple so everyone could understand how/why/etc.. But yet - you did it here brilliantly, If I was still teaching part time (for fun) I'd have totally have stolen this explanation :D And your Newton explanation was top notch too. (I doff my hat to you sir)
@HeavyD6600
@HeavyD6600 3 года назад
Thanks for these videos, Dave! They're great!
@DavesGarage
@DavesGarage 3 года назад
Glad you like them!
@beahydrated
@beahydrated 2 года назад
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
@Real28
@Real28 3 года назад
I remember getting Q3A when it came out and being in the Beta. It was definitely SUSPICIOUSLY fast.
@piobu5357
@piobu5357 3 года назад
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.
@felicksos160
@felicksos160 2 года назад
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.
@luisdanielmesa
@luisdanielmesa Год назад
I first discovered the video from Nemean called "Fast Inverse Square Root", I go back to that from time to time... Let's see how good this video is, with a fresh set of eyes explaining everything...
@paulmichaelfreedman8334
@paulmichaelfreedman8334 3 года назад
Still playing Quake III Arena nearly daily. Yes still, after 22 years. Your Bday? Congrats!
@DavesGarage
@DavesGarage 3 года назад
Wow, I wasn't sure if folks still play it but that's cool!
@paulmichaelfreedman8334
@paulmichaelfreedman8334 3 года назад
@@DavesGarage Not a whole lot of servers around anymore, but a few is enough :D
@lobotomizedjellyfish2171
@lobotomizedjellyfish2171 3 года назад
@@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!
@quadro1337
@quadro1337 Год назад
@@lobotomizedjellyfish2171 yep UT99 is still alive, but u will probably end on a server full of chads, who will 360 headshot you midair ; D
@FluffyAnvil
@FluffyAnvil 2 года назад
But why is this attributed to Mike Abrash who has absolutely nothing to do with this? This algorithm was invented by Greg Walsh in the 80s. Mike Abrash is a legend but give credit where credit's due.
@Mattski_83
@Mattski_83 3 года назад
"Give it the old double thumbs down" I found this way more funnier than it probably was.
@aronseptianto8142
@aronseptianto8142 3 года назад
can i say, inventing the literal format for world's bulk of computation need is one hell of a legacy the kind you won't be remembered for, but the kind that will last
@jonasglanshed
@jonasglanshed 3 года назад
The FISR is another proof of what an absolute unit of a programmer John Carmack is.
@paulgray1318
@paulgray1318 3 года назад
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.
@Ferdam
@Ferdam 3 года назад
I think that with limitations, comes the creativity (to overcome them) It is pretty nice to see limitations as challanges sometimes.
@natetolbert3671
@natetolbert3671 3 года назад
THIS is the side of programming I love. Whatever happened to blazing a trail? This is why I started and now the unknown no longer exists. Is this just me? Does anybody else ever get the feeling that trying something else (now it is less about algorithms and more about the abstractions and object models that lay above, but the addage still applies, imo) is just called "the wrong way."
@RossMcgowanMaths
@RossMcgowanMaths Месяц назад
I unravelled this algorithm. Basics are the mantissa ranges 0 to one the log base 2 can be approximate from 0 to one by a simple linear approx. The inverse square root can be written in terms of a logarithm which we replace with the linear approx. Once you work through it as a maths guy it's quite simple. Of course as a maths guy I know enough to pre.ise this with everything is simple once someone else has ready done it for you.
@Gunbudder
@Gunbudder 2 года назад
i had just started programming when FISR started making the rounds. i will always have fond memories of it
@Rasterizing
@Rasterizing Год назад
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!
@microcolonel
@microcolonel 3 года назад
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.
@piotrd.4850
@piotrd.4850 3 года назад
Well, these were golden years of Computer Science. People who went through thorough basics, unbriddled experimenting, had passion, imagination, fewer distractions and worked hard. They did demo scene intros, fought with debuggers, understood machine internals, knew assembly and architecture (which was possible back then...) and were constantly creatively pushing the envelope.
@ToBeeOrNotToBeHoney
@ToBeeOrNotToBeHoney 3 года назад
You tease.... good stuff so far, brings back memories of coding in cad display drivers in assembly...
@marcosgazamanes6165
@marcosgazamanes6165 2 года назад
Happy Birthday Dave! Thank you for sharing all this, it’s always fascinating!
@andrewthomasfinney752
@andrewthomasfinney752 3 года назад
I was using CAD in the late 80's, specifically AutoCAD and while watching this remembered that the PC's of that time were useless at running it unless there was a separate maths processor on board!
@DavesGarage
@DavesGarage 3 года назад
Yes! Back when it mattered if you had a 287 or whether it was an SX/DX chip!
@PatrickAustin
@PatrickAustin 3 года назад
Happy Birthday Dave...thanks for the great videos!
@DavesGarage
@DavesGarage 3 года назад
Thanks 👍
@natetete1379
@natetete1379 Год назад
Is "evil floating point" the official comment on that bit of code? That's fantastic.
@NolePTR
@NolePTR 3 года назад
Love this channel. Thanks for taking the time and sharing these stories.
@RicardoMontee
@RicardoMontee 3 года назад
10:34 haha "A good compromise means everybody is a little unhappy."
@DavesGarage
@DavesGarage 3 года назад
I don't know if that counts as "a saying", but I've always found it to be mostly true!
@AirZeee
@AirZeee 3 года назад
I confess, I'm 45 years old, rarely use Math beyond the absolute basic in day to day life, so have at best a weak grip on much of this, but Dave, well you're such an engaging host that I keep coming back for more! :D
@dvandamme00
@dvandamme00 3 года назад
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
@tursilion
@tursilion 3 года назад
Very nice explanation... but what caught me the most was I also have a Sharp EL-5103S that I got from my grandmother for my first year of high school. That was in 1989 and I've only had to change the batteries once. It still works!
@quesoestbonne
@quesoestbonne 2 года назад
I got mine sometime around 1978/9. Be wary of leaving it in the original the plastic wallet these days, the brown plastic on mine started to decompose last year leaching out sticky plasticiser all over the calculator. Messy to clean up and has fogged the disply.
@xxIONBOMBxx
@xxIONBOMBxx 2 года назад
This video will explain the fundamental beginning of the first person 3 dimensional video games we play and crave today. What a Lad
@BudoReflex
@BudoReflex 2 года назад
I worked in a building company where every lunch time we would turn out the lights and play quake 3. We went on to unreal tournament later. Quake 3 had such an influence on me i designed my house with the environments it had impressed on my mind. Happy Days. After completing unreal tournament, (by finding a place to hide), i never played a first person shooter again. Apart from a bit of halo, of course. 😉
@sigstackfault
@sigstackfault 3 года назад
Fun fact: my dad is currently shipping an embedded product which uses fast inverse square root for calculations related to the accelerometer and gyro
@jamesgann560
@jamesgann560 3 года назад
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!
@deus_ex_machina_
@deus_ex_machina_ 3 года назад
Man this has got to be the only time I've subscribed based solely off an intro. Excellent storytelling!
@rainbain5474
@rainbain5474 Год назад
It's a pretty good algorithm. It's cool how the stuff at the front only takes one ceaser operation to reach good enough outputs. I have used it a few times, but most of the time I stay away from it. The strange outputs can confuse people if you use it in a library and on a GPU square root is pretty well done by the DSPs. I have programmed a fair share of floating point hacks, nothing that crazy, but its a good lesson to know that you should know how your data is represented at the binary level because many operations can be simplified and give you a better since of what approaches to a problem would be the most efficient. What you do and do not need floating point hardware for, etc. Most people could not convert a decimal in base-10 to a float by hand, and given it may take me a few tries I'm bad at it, but I wish floats where not as much of a mystory to as many people as they are.
@bsdetector837
@bsdetector837 2 года назад
Good video, just wish you went a bit faster, though I understand that some people watching your videos may not have the background knowledge to know what’s going on. I’m a math major and I do software. Most of the concepts are trivial, and I’m only impressed by the way he came up with it. I’m not nearly as good at coming up with solutions myself as I want to be, so I’m fascinated by the insane creativity and outside-the-box thinking of others. Still hit that like button, and subbed.
@LoesserOf2Evils
@LoesserOf2Evils 3 года назад
From Japan: デイヴさん、お誕生日、おめでとうございす! /deivusan otanzyoubi omedetou gozaimasu/ Happy Birthday, Dave!
@SeanCMonahan
@SeanCMonahan 3 года назад
Learning that IEEE-754 was invented by one person was pretty cool. I'm excited for part 2!
@michelecarla598
@michelecarla598 3 года назад
Don't think that was the case... Several people were involved and probably none of them payed by Microsoft (although I could be wrong on this last point). People tend to get carried away while telling stories.
@gesh92
@gesh92 3 года назад
OMG, my mom has the same calculator from the 1980s when she studied math at university in Bulgaria :D Still works today with no battery replacements...
@Bdoserror
@Bdoserror Год назад
@12:15 - I still have my EL-5103S too. Got me 3/5ths of the way through my Comp E degree before matrices became a big part of my work. Then I broke down and got an HP like everyone else, but the 42s instead of the 41C that everyone else had.
@74Gee
@74Gee Год назад
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!!
@nicolabombace2004
@nicolabombace2004 3 года назад
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 :)
@machfaive5159
@machfaive5159 Год назад
Such nice Jazz playing in the background, loving it.
Далее
REVEALED: The Quake III Secret Algorithm! Part 2
20:12
Просмотров 257 тыс.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Дежавю, прескевю и жамевю!
00:59
Does Windows have Back Doors?
17:05
Просмотров 283 тыс.
The Truth about the Fast Inverse Square Root on the N64
10:01
Someone improved my code by 40,832,277,770%
28:47
Просмотров 2,5 млн
What Causes a "Blue Screen" Crash?
16:27
Просмотров 988 тыс.
This Algorithm is 1,606,240% FASTER
13:31
Просмотров 815 тыс.
How Karatsuba's algorithm gave us new ways to multiply
18:48
Emulating a CPU in C++ (6502)
52:28
Просмотров 979 тыс.
The Secret Society of Code Reviewers at Microsoft
18:34