📏Lerp vs Slerp⭕ • Lerp interpolates in a straight line • useful for interpolating positions • Slerp rotates around (0,0) • useful for interpolating directions #unitytips
@FreyaHolmer Worth a link to @jonathan_blow and @cmuratori who both wrote a lot about this back when we all were really pushing for fast and accurate animation tech. http://number-none.com/product...
@beachgrub @FreyaHolmer @Jonathan_Blow (BTW Jeff, it turns out this is not about rotations, these are _vector_ interpolations, so the Blow article isn't really related).
@cmuratori @FreyaHolmer @Jonathan_Blow Yes, I realize he was doing a Vector3.Lerp in this case. But I find this topic a constant source of confusion. Even my Unity coders mix Lerp, Slerp, and MoveTowards all the time. I often see Update() { rot = Quaternion.Slerp(rot, targetRot, speed * Time.deltaTime); } .....
@cmuratori @FreyaHolmer @Jonathan_Blow which "kindof" works so they don't see why it is wrong. But they meant RotateTowards in this case. Doesn't help that the interface names are easy to forget. I figure the more people reading about this topic from smart people that know how they should be used is great.
@Jonathan_Blow @cmuratori @FreyaHolmer exactly. The lerps are 0-1 but you are putting basically a constant in there at each step and depending on the distance and speed it behaves differently.
@beachgrub @Jonathan_Blow @cmuratori It's a useful smoothing method for when you have a moving target, and you want it to move there faster when further away, and slow down when it's closing in for instance, making a thing smoothly follow your cursor thing.pos = lerp( thing.pos, mousePos, c * dt )
@Jonathan_Blow @beachgrub @cmuratori Isn't what? useful? I mean, that's just, not true? Not sure how to answer that As for the quaternion lerp - Unity has a Quaternion.Lerp function separate from Quaternion.Slerp, and they behave slightly differently as shown in the animation!
@Jonathan_Blow @beachgrub @cmuratori ...I included dt? it's framerate independent enough ...and why did the goalposts suddenly move to "high-quality" 50+ years maintainable code? also fuck off with that condescension, assuming I think this is a mystery or that I don't know my shit
@Jonathan_Blow @beachgrub @cmuratori I know it doesn't make things fully framerate independent which is why I specifically said "framerate independent *enough*" I have tested this in exactly that way, it's fine, I know about its limitations, but it still does does have a lot of use-cases when it comes to smoothing
@Jonathan_Blow @FreyaHolmer @beachgrub @cmuratori looks pretty hecking similar to me 🤔
@Jonathan_Blow @FreyaHolmer @beachgrub @cmuratori ah yes, I too love to zoom into the incredible subpixel calculations of a game to find that the position of something is 0.0014 units away from where it should be, truly a gamebreaking bug
@Jonathan_Blow @syranide @khyperia @beachgrub @cmuratori Blocking is often a pretty good option for when you don't want to deal with uncharitable nitpickers who do nothing but drain your energy
@syranide @Jonathan_Blow @khyperia @beachgrub @cmuratori Of course it depends on the situation. If you are working on a physics engine and very timing sensitive stuff, sure? My point isn't that that's not useful or valuable, my point is that the lerp smoothing *can be useful*, because it's often framerate independent enough. That's it
@syranide @Jonathan_Blow @khyperia @beachgrub @cmuratori My issue with the nitpicking, is that I merely said it was *useful* Then I get Jonathan over here literally going "It really isn’t, though" as a response to me saying it's useful Did I say it was the perfect solution? Did I say it was mathematically accurate? No, what the heck
@syranide @Jonathan_Blow @khyperia @beachgrub @cmuratori Followed by "I don’t understand what “quaternion lerp” means on that 3-thing-comparison diagram..." which in an of itself sounds dismissive, as if I'm using a silly term for it. The added ... at the end really makes it. He could just, ask, you know, or look it up?


