FAQ! *Q: What about lerp(a,b,F*Δt)?* A: That's an approximation, and it happens to be a pretty good approximation! Especially if you are running at a high framerate, but it can falter pretty violently if you get lag spikes, or if you use large values of F. Even if you clamp it to not overshoot a value of 1, you can get disparate outcomes depending on framerate. Now, this whole talk is about half of what my (upcoming) blog post will cover! In the blog post, I spend a *lot* of time talking about approximations, including this one, and exactly where and how it fails c: *Q: Can't you just use a fixed timestep loop, separate from the rendering update loop?* A: You totally can! But if your fixed timestep is lower than your render framerate (which it usually is - unity defaults to 50fps in FixedUpdate for example), then you now have a new problem. Your motion will look stuttery because the position isn't updated as often as your rendering is, and so now you need to make it interpolate across those gaps before the next FixedUpdate hits. Now, in unity specifically, and specifically for rigidbodies only, there is support for interpolation, if enabled. However, keep in mind that this is an additional hack/patch, on top of your initial hack, of not using a framerate independent smoothing method. Personally I prefer just to use the framerate independent variant at the render framerate, unless it has to be a part of some existing timestep ecosystem, such as when you want it for rigidbodies *Q: How did you make these slides/animations?* A: It's a long story! Usually I use unity together with my animation tool + shapes, my vector graphics library. But this time around I used html/js/css, since this started as a (yet to be released) blog post on the same topic. I use html5 canvas to draw 2D graphics, and I use KaTeX to convert LaTeX into html elements. Pretty much everything else is custom made, from the slide nav to the interaction to the animations etc.! I have actually considered making a video about my descent into web dev in making this, because I have OPINIONS about javascript, lordie christ ;-; *Q: Will you publish the slides?* A: I already have! They're available for all my patreon supporters right here! www.patreon.com/posts/105228270 *Q: Will you publish something about the spring physics you showed near the end?* A: Eventually yes! likely on my blog as well, maybe as part of the lerp smoothing blog post, or as its own separate thing afterwards since my lerp smoothing post is already enormous
@Werbel5 ай бұрын
Q: What about the y′′+2ζωy′+ω2y=0 ? It looks interesting, but even chatgpt dont know that and only 2 pages on google, not really mentioning a code! Show me a pseudocode for that pretty please :). Or confirm K1 K2 K3 K4 solution by chatgpt.
@youtubeviewerxx5 ай бұрын
PLEASE do make that video about web dev. I am trying my hand at explanation-blogging and it's not easy, I want to see how you do it with your kind of quality.
@telephonedude5 ай бұрын
> because I have OPINIONS about javascript, lordie christ ;-; I am putting this post on my Christmas wish list. I recently fell back into wanting to do some web dev, and... yes. Lots of opinions, lots of feelings :')
@redpepper745 ай бұрын
That's super cool, I'd love to see your thoughts on web dev, especially how you're doing the canvas stuff. Right now I'm working on my first browser game (it's a picross/nonogram clone) and I'm only using the canvas, so it would be neat to hear about how you achieved certain things like smooth animations and making it run efficiently.
@sheepcommander_5 ай бұрын
i need to know how to perfectly lerp
@guidosalescalvano98625 ай бұрын
Freya is such a rock star educator that people are queuing in line to watch her teach something.
@acegikmo5 ай бұрын
literally though?? I don't think it's visible in the video, but there were *so* many people, including a crowd gathered, *standing* behind all the (filled) seats. after my talk I spent about 3 hours nonstop talking to people who had questions! it's weird, but also really fun and flattering ❤
@TheDavidlloydjones5 ай бұрын
@@acegikmo Well, Guido has it right. I don't know how the hell this got into my feed, but it's a pleasure to run across you for sure! 🤩🤣
@mario_actually5 ай бұрын
@@acegikmoit’s so well earned. Absolutely S-rank.
@maxrinehart41775 ай бұрын
@@acegikmo that proves that you are knowledgeable, intelligent, has the rare skill to teach others, and kind person.
@hydropage28555 ай бұрын
“her”?
@javierlim48735 ай бұрын
Cool connection at 16:30: It takes 53 iterations of halving. The mantissa of a 64bit float only has 53 (effective) bits of precision. This is not a coincidence! Specifically, a float is stored as 1.mantissa x 2^exponent, where the mantissa is a binary number. The number closest (but not equal) to 2 is hence 1.111...1b x 2^0 with 53 1s, equal to 1.99999999999999977795539507497 in decimal. Up to rounding, this is f(52) shown in the video! On the next iteration, there is no nearer representable number -- it simply rounds to 2! And indeed, it takes 52 iterations to get to this point, because at the nth iteration, a is 2^-n away from 2. The difference between 2 and 1.111...1b? 0.000...1b = 2^-52!
@octopodes_nuts5 ай бұрын
Bonus points if somebody knows how many iterations the example would have taken to get from 1 to 0 instead of to 2, taking subnormals into account
@atomictraveller5 ай бұрын
44100 is a constant you may be aware of. if not, you're too young. 44100 is a quarter, times 420, times 420. a quarter
@abebuckingham81985 ай бұрын
I feel like 2^-52! is overkill. Could have just been 2^-52. 😏
@F_A_F1235 ай бұрын
@@abebuckingham8198 2⁻⁵²! is actually around 1
@hornylink5 ай бұрын
@@F_A_F123 people don't respect the need for precision nearly as much as they should. why shouldn't we just round pi to 3.14? what could possibly go wrong?
@Teflora5 ай бұрын
I'm going into the video thinking "oh yeah, I know that" and in the middle of the talk you go deeper into a topic than I ever did and learn something new. It's amazing! That's why I always watch your videos!
@error.4185 ай бұрын
100%, she gets me every time
@acegikmo5 ай бұрын
haha, good! I generally try and capture as many people as possible in the beginning, so that the more advanced stuff is built on a foundation I've communicated, rather than assuming everyone knows that stuff already. sometimes it's useful to get reminders of things you already know too, so I think it's worth it! even if some people might find it basic or boring for a bit
@MetapeterUndMetagreta5 ай бұрын
@@acegikmo Absofuckinglutely!
@ere4t4t4rrrrr45 ай бұрын
@@acegikmo so I was reading the newly released Tom7 paper (called Badness 0, it's on HN frontpage) and he was talking about how some people explore subjects "depth first" and he gave an example of Donald Knuth. I was just thinking how your videos have so much depth too
@ThePoke1515 ай бұрын
Freya = the best math teacher I had + cat ears
@KangJangkrik5 ай бұрын
If my teacher wears cat ears, I would never sleep in the class again
@Rizzmaster90015 ай бұрын
i didnt even notice the cat ears lmao
@Wawwior5 ай бұрын
Cat ears are a subset of best teacher ever criteria
@AtomicAndi5 ай бұрын
Around 1999 there was a car racing game called Screamer, which was great, but the tire grip depended on framerate. The slower your PC the faster you could take corners. I replayed it years later at 200fps and there was virtually no grip, like driving on ice
@adsilcott5 ай бұрын
Rollcage came out the same year and was one of my favorite PC racing games, but it had the same problem. I loved that game but when I convinced a friend to buy it and tried to play him vs, he said that the steering was really bad. I thought he just needed to get good until I tried it myself. His system was faster and the steering was clearly tied to the frame rate. I thought that was an amateur mistake by the developer, but this talk has convinced me that it's a more subtle problem than I thought, and I've probably made similar mistakes in my own game development.
@alejogonzalez49975 ай бұрын
@@adsilcott Oh, you don't have to go so far back, in F1 2022 and 2023 (don't know about 2024), physics are framerate dependent. I mean, you don't have 0 grip at high framerates, but with a low enought performance you could almost ignore curbs. Also, random fact, I was searching for Screamer, and it seems that the studio is now the one that works in Moto GP games, Ride franchice, the new Hotwheel game and some more.
@curryleavesbydhanya5 ай бұрын
Need for Speed: Rivals (by EA) has the whole physics system tied to the framerate. If you are lagging the whole game will play slower, and if you unlock it to high fps the game plays like a timelapse
@AtomicAndi5 ай бұрын
@@curryleavesbydhanya wow, that's bad for a "modern" title. You could also have slowmotion in Grand Prix 2 back in 1996, when the PC was too slow, but apart from that it was accurate
@whynotanyting5 ай бұрын
"Shit! I fixed it!" Debating whether that's a good or bad thing to hear a coworker say
@catmacopter85455 ай бұрын
If you just don't mention it, they'll put the bug back in the code and get free job security. So that depends on what you think about keeping that coworker around!
@alextasarov13415 ай бұрын
@@catmacopter8545if the fix was an accident and they aren’t sure why it is fixed, it can be vexing to not know the origin such that you could prevent it from recurring.
@oriandon225 ай бұрын
i'm a mathematician, and i love your stuff! i show your videos to my students as supplemental material and they find it soooo helpful. keep it up!!
@brandonsaffell41005 ай бұрын
Great discussion. How to convert from a per frame implementation to a time based implementation should be game dev 101, but we've seen plenty of AAA game companies fail at it.
@05degrees5 ай бұрын
Yeah.
@mickaelgodard5 ай бұрын
I dont have a memory of a recent AAA game failing at framerate dependent bugs.
@darthnix5 ай бұрын
@@mickaelgodardevery game that ties physics to frame rate and locks your game at an fps because of it is a failure
@mickaelgodard5 ай бұрын
@@darthnix Agreed, but which one did that recently?
@darthnix5 ай бұрын
@@mickaelgodard name any Nintendo game
@Maxawa08515 ай бұрын
'babe wake up new hour long freya holmér presentation just dropped'
@Spine2235 ай бұрын
so real
@MooImABunny5 ай бұрын
6:22 oooh dimensional analysis is great! I love it, glad you learned about it. It doesn't solve everything, but every once in a while it lets you skip some hard work
@SeanCMonahan5 ай бұрын
It's also a check that your calculations make sense to begin with, that the units at the end have the dimensions you actually want, so you don't waste a bunch of time, say, finding a neat, closed form solution to a nasty, nested integral that is actually fundamentally wrong 🙃
@torylva5 ай бұрын
Hi Freya, you probably don't remember me in particular, but I hope you remember my class! Me (and hopefully everyone) from Futuregames 2022 Game Programmer just wants to say "thank you!" for all you did for us! I was saddened that you got sick for our other course with you and I hope you feel much better these days! Every time I think of Lerp, I think of you! With loving regards, an alumni from FutureGames!
@acegikmo5 ай бұрын
@pinkeHelga5 ай бұрын
@@acegikmo Oh no! You're not a teacher anymore? What are you currently doing?
@pinkeHelga5 ай бұрын
@@acegikmo And now I'm confused... why is this verified account not 'Freya Holmér' but 'acegikmo'?
@acegikmo5 ай бұрын
@@pinkeHelga because KZbin decided to start showing handles instead of display names in comments for some weird reason
@Kobold6665 ай бұрын
@@acegikmo Handles are unique, KZbin ended the fun of trolling by impersonating other people in comments. Took them almost 20 years.
@angeldude1015 ай бұрын
If df(x) = af(x), chances are good you have an exponential; _the_ function whose rate of change is proportional to its value. Fun fact, a 90° turn is legally a constant proportion, so circular motion, whose rate of change is a vector 90° from its current position, is also an exponential. Often this "90° turn" is written as "i", so circular motion is expressed as e^it, which may or may not equal cos(t) + isin(t). Now we just need to do _spherical_ LERP smoothing along a B-spline of dual-quaternions, and we'll still probably not have the most complicated way to get from point-A to point-B.
@cineblazer5 ай бұрын
This is the first explanation I've heard of complex exponentials as sinusoids that has actually felt intuitive to me! Crazy to have stumbled across such a gem in a KZbin comment section :) I hope you have a wonderful day!
@APaleDot5 ай бұрын
@@cineblazer Yep, the hallmark of circular motion is that the velocity is always perpendicular to the displacement from the center of the circle. With complex numbers, you just multiply by 'i' to rotate by 90°. So you could say that the velocity is just the displacement multiplied by 'i' (or some constant multiple of 'i'). Since exponentials are always proportional to their derivatives, as shown by d(e^(ax)) = ae^(ax) dx, we can see that if the displacement is s(t) = e^(it) then ds(t) = v(t) = ie^(it) dt. So we have v(t) = is(t), fulfilling the requirement for circular motion.
@angeldude1015 ай бұрын
@@cineblazer Any function that only depends on a prior position and a time since said position can be described as an exponential. This includes exponential growth & decay, rotations, and even in a way _translations._ This even relates to the limit definition of the exponential exp(x) = lim n->∞ (1 + x/n)^n, where you're essentially breaking x up into infinitely many small chunks, and then repeatedly scaling the identity by the 1 + a single chunk. Whether that's by repeatedly eliminating 30% of a set of remaining dots, or simply taking one step after another to slowly inch your way across a mile, they all boil down to the same concepts. There are no coincidences in math; only special cases.
@timmygilbert41025 ай бұрын
Wait isn't that just tan(a)?
@minerharry5 ай бұрын
Another secret is if you remember from Freya’s “why can’t you multiply vectors” talk, i is a unit bivector - an oriented plane segment representing rotation. The fact that e^i represents rotation is then no coincidence! In fact, with the 3D bivectors i j and k, if you have some bivector B = a*i + b*j + c*k, the *exponential* of that bivector e^(B*theta) works **exactly** like e^(i*theta) - it gives you a rotor* representing the rotation in the plane of the original bivector by the angle theta. Just like the exponential discussed, the bivector itself is another constant value - in fact, as alluded to in her talk, it is **the circulation bivector!!** This means that the formula for following a curve can be described as iteratively applying e^C(t)dt (or the corresponding integral). [I think the formula’s right I may be off by a few factors] *rotors are only mentioned briefly in the talk, but they are just scalars + bivectors. You need scalars as well to represent arbitrary (non-90*) rotations for the same reason you need scalars in complex numbers.
@dr.kraemer5 ай бұрын
Gotta admit, at this point I see Freya, I click.
@dr.kraemer5 ай бұрын
(I'm not sure I'd even encountered the word before, let alone considered how to smooth one.)
@favalon795 ай бұрын
I love Freya’s talks, where she explains things with beautiful animations and cats icons
@colonelwatch92205 ай бұрын
Hmm, not a game dev but I find it fascinating that the same smoothing idea can show up in many places. In game dev, it’s lerp smoothing. In finance, it’s the exponential moving average (EMA). In my field, electrical engineering, I also just call it the EMA, but others call it the exponential filter or even the “1-pole IIR filter”. And, well, I never considered going about this issue without bringing up Fourier and cutoff frequencies, but here’s an explanation using just algebra (not even calculus!). Like, I never made that connection between the framerate dependency and the decay. Very interesting… EDIT: I remember now you mentioned that you do that clamp to prevent wiggling. When that’s done, it does becomes slightly different from the EMA. What you’re seeing is probably the Gibbs phenomenon. It takes particular filters like the Bessel filter to get rid of it without clamping, but I’ve also seen people just do clamping. For example, some variations of JPEG rendering do this so that you don’t get JPEG artifacts.
@npatch5 ай бұрын
FWIW, I used this for smoothing out joint animation data coming out of a Kinect sensor. Sometimes joints jitter, so you can use this to smooth out the outcome without keeping history of data (other smoothing filters tend to need data from previous frames to do so). It's like the lowest hanging fruit smoothing.
@matercan56495 ай бұрын
I love the cat ears, never thought a mathematician would be wearing nekomimi.
@sakura_x645 ай бұрын
@@tbird-z1r she isn't, but you are
@cineblazer5 ай бұрын
@@tbird-z1r Honest counter-question-why do you care? Why is the gender she was assigned at birth something you want to know?
@sakura_x645 ай бұрын
@@tbird-z1r how is that relevant?
@acegikmo5 ай бұрын
hmm, I think for me the cringiest part is that I didn't get a haircut before this event, my style works much better when my wavy inverted bob cut is properly showing, but now that it's grown out it just kinda looks awkward-medium length wavy
@acoust1c345 ай бұрын
@@acegikmoyo I know nothing about gamedev or smth you doing, but I think you are not awkward and kinda cute really. goals tbh, maybe in 1-2 years all be a programmer/gamedeveloper wearing cat ears too ❤ you make it sound less confusing so thanks
@leroymilo5 ай бұрын
Thank you so much! I used lerp smoothing for a project and I fully understood all its issues, but I had no idea how to solve it. This was very useful!
@acegikmo5 ай бұрын
yeah, it's one of those "it's close enough to working and I know it's wrong but it seems mostly fine so I'm going to ignore it until it becomes a problem" things you know
@kepstin5 ай бұрын
I saw the graph of the lerp smoothing function, and realized that it looked identical to a smoothing function I was using on some sampled data to clean it up - the "exponentially weighted moving average". I recently had to reformulate that to handle data being sampled at uneven intervals instead of at constant intervals… basically, making it framerate independent :)
@Zondac5 ай бұрын
LOVE your ability to take concepts i genuinely thought i knew almost everything about and then expand on them until even someone who’s been doing this stuff for a long time learns something new. Even concepts i was fairly familiar with you explained in a way I hadn’t exactly heard before, which helps recontextualise the tools we depend on!
@paulbunyangonewild75965 ай бұрын
once i saw those cat ears i knew i was listening to a professional
@Krunklehorn5 ай бұрын
The exp() and exp2() methods also approach 1 asymptotically and thus, naturally prevent overshoot, even at extremely low framerates.
@unflexian5 ай бұрын
freya more like feynman with how much you make learning feel like discovery
@a_soulspark5 ай бұрын
hmmm... with the cat ears, why not call her feynyan?
@JoBoToGo5 ай бұрын
I'm not a game dev, and I don't currently have any use for this awesome technique, but learning about it from you made my brain tingle in the best possible way, thank you!
@christianloose98755 ай бұрын
I'm not a game developer nor a mathematician. But I could still follow most of this talk with my school math and software development background. It's very interesting and brilliant talk. With videos like this, KZbin has real value instead of being a time waste. Thanks!
@pavelperina76295 ай бұрын
When I tried to solve similar problem I somehow realized that there's relationship between log and square/cubic/...-roots and I actually don't understand why these relations work. Or why there are even things such as fractional powers and roots. And how logs turn multiplication to adition. I took old slide rule and started to reverse-engineering it to the level I was able to independently reinvent logarithms (having advantage that I had some clue what I'm doing) and find them using square roots iteratively (which are basically fractional powers). It was nice feeling when all puzzle pieces worked together. After half year, I almost forgot everything I learned.
@Duiker365 ай бұрын
Yup. It's always a bit of a surprise how much of math can be broken down and understood like that. Part of the problem is that, in school, we are told to memorize how it works and then process stuff like a computer. It makes math feel scary, since we aren't computers. But when we have some idea of what we're trying to do, and why it's important, and have some time to poke and prod at how stuff works, it's remarkable how much of math just *falls out* naturally. It's what mathematicians mean when they say it's beautiful.
@Houshalter5 ай бұрын
Understanding logarithms and those relationships has been the most useful and magical bit of high school math for me. It comes up everywhere. It's amazing humanity didn't discover it until modern times.
@acegikmo5 ай бұрын
yeah! fractional/rational powers are really unintuitive! I think most people start using them around the time you start using calculators though, and so I think it largely goes unquestioned even though it's (as far as I know) also often unexplained around the time of high school, at least it was in my case! I really wanted to go on a tangent about rational exponents in my (yet to be published) blog post but it's already ridiculously long so I ended up cutting it 💀 maybe I'll save that for the future!
@AquaEBM4 ай бұрын
Fun fact, we just discovered (with a cool perspective twist) Exponential Moving Average (EMA) smoothing, Very commonly used in DSP-related fields, like audio (smoothing parameter changes, to avoid gittery clicks in your audio), embedded (de-noising signals captured by sensors). This technique is a way to efficiently discretize exponential function(s), which, needless to say, ubiquitously model many physical phenomena. Awesome talk Freya!
@grim_glim3 ай бұрын
I got an ad break with some lady who asked: "Are you having a hard time understanding calculus? Are you having a hard time understanding your instructor?" And the answer is no, this was a very clear presentation, neat
@SulekSkelux5 ай бұрын
Omg it's been a while, I'm so glad you're still making educational content
@collin45555 ай бұрын
Well, I was happy about anticipating the framerate dependence issue, and then it was a thrilling hour of hoping to keep up with the math. Exactly what I came for!
@blubbarbs5 ай бұрын
This is actually insane that I was running into THIS EXACT PROBLEM over this weekend. I was porting over a minigame from TF2 called dodgeball into Minecraft and they used a LERP function to make the "ball" follow the player. The issue is that TF2 ticks at 66tps and Minecraft does 20tps so it was feeling different. Long story short I also found one of the equations you described to solve the issue, awesome talk :)
@directrix15 ай бұрын
I am consistently impressed with how well you present this type of material. Always well made, and always worth the watch. Thanks!
@dominiquefortin53455 ай бұрын
@Freya Holmér Great work of vulgarization of the lerp function. It is always nice when all this research and exploration is put into a nice little narrative. I'm sure it took (x * 1h, where x > 3) to prepare. Continue to share with us your enthusiasm about computer graphics. I, my self, am interested PIDs control and lerp is kind of open loop control.
@atomictraveller5 ай бұрын
lerp is linear interpolation. it's being able to go in a straight line between two 1D locations. it's as elementary as elementary math can be. this is not an education.
@aldanasjuan5 ай бұрын
This is awesome Freya, I just tested the TLDR code and it works well. I love that if you use < -1 in the decay it will repel. I'd love to see the TLDR copy-paste version of the spring function but I'll wait for the blog post. Now I have to replace all those bad lerps in my game, which I'm grateful for knowing frame independence is closer.
@Spine2235 ай бұрын
hey you really inspire me; I could never get up and teach.. but self-teaching and getting out there seems great
@FlameRat_YehLon5 ай бұрын
I guess the best attitude towards math is to have fun with it. When there's a dire situation by no means search the answer for it, and one shouldn't feel shameful doing it because time is precious especially for development work (where work can't really be divided much). But when there's leisure, well, that's when to really know what's inside. Knowing the answer of random what-ifs always brings fun, and so does feeling the power in knowledge. Like, because knowledge is power, learning new knowledge really gives the power fantasy vibe, which feels really good even if those knowledge will just go wasted. Also, love how you got the cat ears on perfectly! It often feels really hard to get cat ears on without them looking slightly off or asymmetric, for whatever reason, almost like there's a curse that prevents cat ears to be worn properly or something.
@frederiklenk77565 ай бұрын
The lerp saga continues Also dang learning quarternions before differential equations feels like the wrong order of things 😂 I for sure assumed you'd have that down before. But probably just my uni bias since i still dont get quarternions but am quite comfortable with differential equations
@APaleDot5 ай бұрын
nah, quaternions are just algebra.
@notnotkavi5 ай бұрын
@@APaleDotyeah agreed, it's just not introduced because within math outside of graphics it's relatively niche
@acegikmo5 ай бұрын
I think it's a side effect of not having an academic background in math, the way/order I study things is entirely by happenstance, so I tend to have a very lopsided skill set
@05degrees5 ай бұрын
@@APaleDot Actually quaternions aren’t just algebra because they for example have a smooth structure. Like complex numbers (well and even real numbers)-complex analysis is even very famous, but quaternionic analysis is a bit bad so it’s usually not that well-known like real and complex cases. And I think one can study differential equations for a long long time, there’s just so much stuff, including hairy analytic stuff and weak solutions and all the worst that math can throw at you. Especially if we include PDEs (really they are a separate subject just for technical reasons and due so a couple of differences in application). So if you even studied ODEs and maybe PDEs at uni and even if you had a math specialty, you can still be far from having a grasp on them that is sufficient for many many areas and tasks. Likewise for quaternions and all other math though: for example I don’t think people usually are aware that you can forget about concrete i, j, k (like we can swap ±i in ℂ, we can rotate the imaginary unit sphere any way we wish and this won’t change any algebra, so if our results don’t directly manipulate with i, j, k, they’re probably more useful etc., compared to if they do depend on occurrences of i, j, k-well, except for quaternion implementation and numerical algorithms, I suppose).
@GameBoy-ep7de5 ай бұрын
At 5:50 when you said to define a conversion factor I went "Ah, dimensional analysis, I'll be impressed if she mentions it" Then you started to talk about dimensional analysis right after and I was somewhat surprised, though I probably shouldn't have been since this seems really professional so far. I'll see if I can understand the rest of the video after this point, and think more than "That seems to have good logic" that is common when stuff above my understanding is described, but still understandable due to good explanations. Edit: I tried to do lerp smoothing in Desmos while watching, and failed. I could follow from step to step but it introduced too many new concepts to nail on a first watch. I'm sure that a rewatch would let me understand it more fully, and then do it in Desmos fine. This was a really nice explanation though, with it being very understandable and clear, and far better than the videos I watched for my Calc I, II, and III classes.
@AerialWaviator5 ай бұрын
A great lesson and future blog post. Love the visual graphics, and read the FAQ (it literally answered the question I had). The nice thing about iterated approximations is they only need to be good enough for the level of context required. With Zeno's example, if walking 1/2-way to a destination, as some point, the remaining distance will be smaller than his foot, so can't take another full step. Same with computer graphics, at some point the next step will be smaller than a pixel. This quantum (minimum iteration unit) could a parameter that stops the iteration process loop, when it reaches a good enough quantum value.
@kolos01395 ай бұрын
I'm only halfway trough, and this is already super interesting and incredibly well made even for me, who is neiter a maths person or in gamedev. Hats off, Freya!
@zactron19975 ай бұрын
Always brightens my day to sit down with some lunch and learn something from a fantastic presentation!
@DetectiveYuki4 ай бұрын
Love this. Your presentation is super engaging. I've decided to take some time to go through your math for game devs playlist as well. Thanks for the learning
@anihopkins67885 ай бұрын
there is absolutely no one better to teach me something about interpolation than a brilliant woman in cat ears
@WeazelАй бұрын
Really appreciated the lecture a few months ago, and just went back to it today to get the code for another project, thanks Freya!
@program759217 күн бұрын
Hey! I had a scroll animation with lerp but it never felt quite right, specially when it was slowing down. now with the expDecay formula it's butter smooth every time! Thank you so much for all the effort in putting this info together =)
@shadamethyst12585 ай бұрын
There's also the fun problem of trying to make the 10fps client match better, or making this work with integers or fixed point numbers. Best solution to the latter I have found so far is to keep have a slower-updating counter, and then go back to using it every time it updates.
@sheepcommander_5 ай бұрын
this doesn't match the 10fps client?
@shadamethyst12585 ай бұрын
@@sheepcommander_ Well, you can see in the slide with all of the overlapping graphs, that there is still some inaccuracy, especially when Freya was moving the target quickly
@sheepcommander_5 ай бұрын
@@shadamethyst1258 In godot i saw people talking about using the Engine.get_physics_interpolation_fraction() but i still don't understand it
@acegikmo5 ай бұрын
@@shadamethyst1258 hmmmm I don't know if I'd call that "inaccuracy", it's more like, it's delayed, because it can't respond fast enough. I guess you *could* extrapolate to try and guess the next frame to stay ahead a little bit, but now you're clearly in the realm of inaccuracy, because now you're adding data that might be incorrect, as opposed to reading correct data a little later than you'd like, right?
@shadamethyst12585 ай бұрын
@@acegikmo Well, I do wonder if a more accurate integration method wouldn't work better; you could always increase the accuracy by just computing substeps, though
@MikkiPike5 ай бұрын
thank you for existing 💗
@KingBobXVI5 ай бұрын
This is actually very useful and topical for a personal project I recently have been working on - it's a game that involves time travel, and at some point while making it I realized that the objects more or less need to have their parameters all defined as a function of time rather than actually simulating stuff (well, there are simulation steps in there as "keyframes" are taken for the player inputs, but their position etc can be derived given any value _t_ - meanwhile, background objects with simple motion (say, constantly rotating gears) can't just do "angle += theta * dt", but have to go by a cosine, etc...). This is some good information on some more complex motions and how to derive them, I'm sure it'll come in handy moving forward!
@APaleDot5 ай бұрын
Speaking of time-travel, the guy who blocked Freya on twitter has a talk about how he implemented Braid. Have you seen it?
@Filup5 ай бұрын
I took an ODE course as part of my degree, and it is pretty awesome when you finally understand everything and can apply it to things like this!
@apotatoman48625 ай бұрын
its time to multiply movement by deltatime
@seedmole5 ай бұрын
So much overlap with audio in this one!! This is essentially the solution to a feature I've wanted to add to a stereo pingpong delay for a while now, but couldn't quite figure out. The trick, I see now, is to raise the per-repetition scaling factor to a factor corresponding to the ratio of frame durations, or in my case delay lengths. Gonna mull this over and see how well it works.. should be exactly what I needed.
@seedmole5 ай бұрын
Hahaha yeah it does work. My thing uses a feedback parameter which is the same as R in this. Tested it a bit, all I gotta do to match the decay curves for two audio delay lines of different duration is raise one channel's feedback parameter to the power of that channel's duration divided by the other channel's duration. That will either slow down the decay of a shorter cycle, or speed up the decay of a longer cycle. Did basic tests and it came out perfect using an analog for integer ratios. Gonna take a bit to implement in the actual audio version but I am very encouraged. Thanks for this and all your brilliant contributions to programming in general, it reaches out far beyond just graphics programming.
@seedmole5 ай бұрын
Audio version implemented and is indeed working. Keeps a stereo image in place as it decays, instead of it splitting apart further and further as the slower side takes longer to decay due to its longer repeat cycle. Very cool!
@acegikmo5 ай бұрын
@@seedmole hah, yeah I've had many people mention audio processing! this is a rabbit hole I've only ever tangentially been around (when making music), but I worry if I look into the math I'll be lost in that world for another 4 years or something
@absolutewisp5 ай бұрын
@@acegikmoUp next on Freya Holmér: The Decay of Soundwaves /s
@AriadneG-19545 ай бұрын
Absolutely loved the presentation, as always Freya, you’re a great science communicator.
@JackLe112713 күн бұрын
I've always written it as lerp(a, b, 1 - pow(1 - alpha, DESIRED_FRAMERATE * deltaTime))
@DrSchischious5 ай бұрын
I really love your content. I'm a cs teacher at a school and really love your educational style. You know how to generate real knowledge in other peoples brains.
@colinbrown79475 ай бұрын
Oh wow! So cool seeing something I had to figure out for myself get explained so well. I was using lerp smoothing to animate a camera following a route on a 3d map, and had to solve for framerate independence. Funnily that approach had a lot of flaws so it got scrapped for a better camera following technique lol.
@johnnysvensson5 ай бұрын
This was great. Thanks for all your cool content Freya! I especially enjoy the math for game dev series and as someone who did ALOT of procedural content generation(mainly procedural textures/graphics, in software on the CPU) before it was cool and before everything was done on the GPU, i also enjoyed the vids about procedural geometry as well as the shader basics one as that is some stuff i need to get updated on/learn in order to stay up to date.
@SeanCMonahan5 ай бұрын
Holy cow, the interactive animations in the presentation are so illustrative! (I'm only partway through at this point.) I've always wanted to do this sort of thing. I imagine it can help give excellent A's during a Q&A at the end.
@TaranovskiAlex5 ай бұрын
Thank you! Awesome talk!
@johningham18805 ай бұрын
Very thorough and intuitive. And I think we now have the P part of a PID controller.
@LucasStraub5 ай бұрын
The visuals on this presentation are so freaking good! It's just perfect!
@Sh4d0wStR1k0r5 ай бұрын
great presentation, as always! as pointed out by others, this is called a one-pole low-pass filter in the signal processing world. they are used all over the place in audio programming, mainly for gently smoothing parameters without overshoot but also directly to filter out high frequencies from any signal. the filter state is updated every tick. in pseudocode, this looks something like: z1 = z1 + (in - z1) * a where z1 is the state, in is the input to the filter and a0 is a parameter calculated from the desired cutoff frequency -> a = exp(-2.0 * pi * Fc), where Fc is the normalized frequency (frequency/samplerate).
@Sh4d0wStR1k0r5 ай бұрын
you can cascade several of these one-pole filters in series to get a steeper filter curve, but you have to introduce a correction factor which is multiplied with the term inside the exp() call, otherwise the cutoff frequency is shifted. something like C(M) = 1 / sqrt(pow(2, 1/M) - 1) where M is the number of one-pole sections retains an attenuation of 1/sqrt(2) at the cutoff point. cascading M one-pole smoothers only requires 2M adds sums and M extra multiplies (as the coefficient stays the same for every section). it's also worth mentioning that there are other implementations of one-pole filters with different numerical properties. since one-pole filters are just leaky integrators, it's possible to implement them using other integration schemes - trapezoidal integration is a popular one, while the "standard" way of implementing one-pole filters corresponds to forward euler integration.
@Sh4d0wStR1k0r5 ай бұрын
another neat thing you can do with one-poles is to efficiently produce exponential curves by pre-calculating the decay coefficient once, replacing an exponential evaluation with a single multiply and add per tick. this is especially useful for producing amplitude envelopes (e.g. ADSR envelopes), where exponential curves produce loudness variations which match our logarithmic loudness perception better than linear segments. it's possible to sidestep the "zeno's paradox" issue by making the one-pole overshoot its target slightly (having it approach a point slightly "beyond" its target) and clamping the output to the actual target value.
@Sh4d0wStR1k0r5 ай бұрын
all linear resonators (e.g. instrument strings/woodwind bores) and essentially all undriven oscillations exhibit exponential decay in their response to a momentary excitation. reverb also decays exponentially after the direct sound stops.
@acegikmo5 ай бұрын
hmmm I've been kinda scared of signal processing because if I start, I'd be stuck in that math snipe for years
@Sh4d0wStR1k0r5 ай бұрын
@@acegikmo i feel the same way funnily enough but with computer graphics, because i'm interested in making audio-reactive visuals for my music (which is "procedurally generated" in realtime, to borrow game dev terminology). so far i've messed around a bit with raymarching and ported some shaders to my programming environment (Cycling74's Max, check it out, i'm sure you'd enjoy messing around with it! there's a free trial version) but i tend to get stuck in these rabbit holes as well
@stevenjensjorgensen5 ай бұрын
As someone who works in robotics, it's so fascinating to see how different developers use the lerp function. During this talk, it's mostly utilized as a low-pass filter, which is a first order differential equation (ODE). So it's not surprising to see the recursive functions and exponentials to be present in the final solution (e.g. solution to the ODE contains e and the Taylor expansion of e looks recursive!) In the literature, the lerp function when used in this way is a particular implementation of a discrete low-pass filter and there's a relationship of how to select the parameter F so that a target low-pass frequency rate is correctly enforced if the known sampling rate, delta time, is known. I've enjoyed seeing Freya derived the inner-workings of the lerp function from an applied first principles approach but without actually calling it a low-pass filter and mostly focusing on the problems faced by developers in the game industry. I also learned something: a = lerp(a, b, 1-pow(r,dt)) is a nice function that enforces smoothing, incorporates frame rate compensation, while retaining the intuitive meaning of the 'r' parameter. But as she mentioned a = b + (a-b)*exp(-decay*dt) is the more efficient implementation. Great job! I think every game dev practitioner can learn something from this talk.
@acegikmo5 ай бұрын
thank you! and yeah, I usually create things from a practical and exploratory perspective, mostly because that's my actual discovery process! and because it usually helps other people like me ease into the concepts :)
@lambdaprog5 ай бұрын
Excellent presentation. I spent a few weeks working around this very problem in SDR# after a crappy Windows update that messed with the timing resolution. The solution involves timestamping and dynamic time compensation.
@yeoman5885 ай бұрын
Your explanation of problem-solving at 51:47 matches exactly with how I like to think, which also jibes with me enjoying your videos immensely (aside from the top-notch production quality). I don't just want to know the solution to my current problem, I want to know WHY it's the solution and WHY it works. That takes more time up front, but if I ever have a similar problem in the future, having that knowledge helps me figure out the solution to the new problem, so I usually consider it a worthy investment.
@TomBrienProfessional5 ай бұрын
Wow this dropped at the perfect time. I used smooth lerping 5 times last week and always thing (Im sure this is more complicated than I think...) I waddled through the talk like a confused baby, and amazingly, I could understand and apply all the options at the end. Wow!
@KarimAktouf5 ай бұрын
It is indeed beautiful and mesmerizing; thank you Freya for explaining it so well
@dealerpriest5 ай бұрын
As always, incredible!
@Zach010ROBLOX5 ай бұрын
I love you just had a mini talk after your talk xP
@ElliotGeno5 ай бұрын
Ha! I love lerping. It always felt so elegant (except for the frame rate thing) As you were talking about solving for R I kept thinking... wouldn't be better to just solve for half the distance or something. THANKYOU FOR DOING JUST THAT!
@ABuffSeagull5 ай бұрын
This is perfect timing! I’ve been working on a custom text editor for myself for fun, and I want the cursor to “smear” around. I was just using earrings, but this’ll make it feel really nice. Thank you so much for this talk!
@libiroli5 ай бұрын
In an alternate timeline Freya ate a bagel instead of a croissant one morning and became an options trader instead of a game dev. (This lesson has many parallels to delta, gamma, theta, and vega in options trading.) Anyway I'm glad I'm in this timeline.
@thomasmewily40125 ай бұрын
Thank for the talk ! I solved a similar problem that involve time integration for school not long ago : You have a population of n rabbits, and each years only 60% survive (inaccurate data). The simulation I was doing was per month and not per year (because of other factors)..., and I needed to convert the 60% survival rate per years to a X% rate per month. So after applying the X% rate 12 times for each month, it need to return to the annual survival rate of 0.6%: pow(x, 12) = 0.6, x = nsquare(0.6, 12) which is x = pow(0.6, 1./12.) The same goes for framerate I guess, with the pow(r, dt) at 37:50. `r` is the coef after a fixed constant amount of time, and `dt` is the elapsed time. I still use this technique in my games The radioactivity example was very relevant, and thanks for the speed comparison with different exponential bases, I was wondering about performances. Also I'm wondering about the Jonathan Blow discussion now x)
@timmygilbert41025 ай бұрын
Damn that ending, DAMN THAT ENDING ❤ free spring is a game changer I don't know if people realize...
@miguelmora58095 ай бұрын
I was there!, I enjoyed a lot your presentation, very stylish as always! It was great to welcome you in Spain
@acegikmo5 ай бұрын
and thanks for joining the talk!!
@dialectricStudios5 ай бұрын
Funny how these ideas appear in many disciplines. From a signal processing perspective lerp is cheap and dirty interpolation but gets the job done - windowed sinc interpolation (FIR style) is the real deal but costs more - an exponential integrator or IIR filter like this uses recursion, is cheap, but has non-linear phase. In this case it's an excellent conclusion. Love it! Power to tha low pass filter :)
@kono1525 ай бұрын
babe wake up freya just uploaded
@usMercurySilver5 ай бұрын
This is a brilliant presentation - I love the attention to detail in the visualizations! It gets me fired up about being an educator.
@tommolldev5 ай бұрын
Wow Vtuber tech has gotten really advanced
@ryuseki-oni5 ай бұрын
I knew off the rip it would land on the exponential decay function, then I was a little stunned that it somehow landed on (...)^n, then I vaguely recalled something from one of the calc's relating (...)^n to exponential decay, then the mention of diffeq caused both delight and mortal dread. :D The term geometric series popped out of the vault, possibly because it was one of the least comfortable sections for me at the time. Keep up the good work!
@OliverBeebe5 ай бұрын
i've tried to tell game dev friends this for a while, and nobody believes me, now i can send them this haha
@dimastorres85305 ай бұрын
I have a PhD and I would love to had you while I was learning molecular mechanics. Thank you very much for sharing ❤
@mickaelgodard5 ай бұрын
Great video once again! Congratualtions. I am in awe for your framework that you use for your videos and presentation. It's so perfect for your mission and it becomes your signature move. Super inspiring. PS: The dig at J. Blow was a bit out of nowhere and unnecessary but funny too.
@stulora31725 ай бұрын
A day with a new video from Freya is a good day.
@maxmustermann39385 ай бұрын
This is also something you sometimes run across in simulations. For example often times some dampening factor to the momentum is used which effectively works like lerp smoothing towards 0 and of course it has those same issues. It's common to multiply the percentage of dampening with delta time but as you explain in your pinned comment that still has issues, the difference can be massive. Especially with simulation, where you might run a low-resolution one with a real-time delta time but run a more complicated high res one with super small delta time. Even worse, if you use delta time then depending on your percentage, you might just lerp with a factor of 1.
@masterytyrantfuture4 ай бұрын
@freya - I agree with your approach to problem-solving. It's much more valuable to understand WHY something works as well as just knowing that it works! You're awesome by the way! 🙂
@andrut5 ай бұрын
Loved the presentation. Thank you. Regarding the final form at 49:37, I think I would prefer to write it in terms of lerp, like that: a=lerp(a, b, 1-exp(-decay*dt)). It's the same thing but I feel it speaks to me better this way, because it looks like the broken version but now it's fixed with the correct mixing coefficient.
@johnbox55405 ай бұрын
freya talks are always so amazing
@causticmango5 ай бұрын
You remind me that I love math, even though I'm not very good at it. Outstanding work!
@danielmilyutin99145 ай бұрын
I loved to watch this! This looks like: coder just discovered math. But more important thing is: be passionate about learning new things!
@hallfiry5 ай бұрын
38:06 I think you can just swap a and b instead of doing 1-pow 😇
@acegikmo5 ай бұрын
yeah, but that's a dangerously subtle change that risks introducing human error and confusion
@supertenchoo42715 ай бұрын
Am happy to see Freya Again wohoo ,lets gooo!!!
@MohamedOsama-mz1mg5 ай бұрын
You are one of the best game programming content creators ever, I hit like now and watch later
@stickguy910911 күн бұрын
Fantastic presentation! Makes it really easy for someome dumb like me understand the maths behind it. I was really hoping you'd talk about making lerp smoothing linear too because aside from lerp being frame dependent it is also non linear as you showed and sometimes that might not be the desired effect.
@zoop3915 ай бұрын
When you said in the end of the presentation during the Q&A that you enjoy doing something fully yourself in order to understand the solution from A to B, I really resonated with you. I've often been criticized for reinventing the wheel or whatever, "Just google it, simple.", okay but I want to understand; "You're wasting your time!", since when was learning a waste of time? I feel like when you solve a problem all by yourself from scratch, there's not just new-rich material ingrained in your mind, but also intuition gets built!
@zoop3915 ай бұрын
Also I realized you have ADHD aswell just like me, apologize if it's another deviation of the condition. But I now am beginning to see a pattern of people with ADHD like you and me just wanting to delve deep into things, litterally get hyperfocused on it and will NOT stop until the solution is present. Maybe it's a coincidence, but I think since our standard dopamine levels are relatively low, that when we are engaged with mathematics, or such a fascinating problem to us, we're so highly stimulated by it that we become fucking sorceries to solve them lol, sounds silly but I genuinely feel that way! I often am able to solve very sophisticated problems because my ADHD drive is fucking insane sometimes, but dangerous sometimes aswell. I remember overworking for companies / comissioners because I loved the work so much, I completely forgot I was getting paid XD.
@acegikmo5 ай бұрын
hah, maybe yeah, I usually attribute my need for detail-digging to my autism, but I have no data to back that up really, who knows! I've just noticed that, on top of *wanting* to dig deep into things, there's also the fact that I often *need* to dig deep to understand something, where others might pick it up faster than me. or at least, that's the only way I've been able to explain the fact that people keep telling me I'm a good teacher even though I've never had any formal training in it
@zoop3915 ай бұрын
@@acegikmo That **requirement** of extra knowledge needed to fully make your brain interpret something is SO GODDAMN RELATABLE! Holy shit, like I felt like I was the only one, but it is a double edged sword because you end up understanding the topic at hand EXTREMELY well, like we're talking like you feel like you could've invented it yourself because you dug so deep, and for me this doesn't only apply for learning, but also just everyday conversations, people get so fucking annoyed when I need them to explain things rigorously, there can be NO PARADOX or AMBIGUITY in their statement otherwise my brain will allocate that paradox and/or ambiguity into my memory and think about that in parallel with what the fuck the person is saying (which by the end of the conversation, will be meaningless enchantment table speech) my brain is like a goddamn c++ compiler LOL (which I think, the majority of us do not like, at all, like at all lol)
@MetapeterUndMetagreta5 ай бұрын
Endlich mal wieder ein Freya-Video und mal wieder lehrreich. Großartig!
@cosmicsnacks1191Ай бұрын
Why do i fall asleep and wake up to all your videos 😭 they do seem really well made though keep it up! (Maybe one day ill listen enough sub conciously ill be able to do shaders
@Fodi_be5 ай бұрын
Thank you Freya, that is super useful! Even though most of the explanation totally went over my head (I'm crap at math), I can still use that function in my projects.
@blonehou85225 ай бұрын
Loved this talk
@seanlpalmer5 ай бұрын
I remember being so proud when I figured this out for myself years ago 😁 this is practically pre-calculus!