An In-Depth look at Lerp, Smoothstep, and Shaping Functions

preview_player
Показать описание
Exploring some common math that game developers use, let's look at linear interpolation and apply it to everything.

Disclaimer: Commission is earned from qualifying purchases on Amazon links.

Follow me on:

In this video, I cover lerp, also known as mix in GLSL, a common mathematical function used in game dev. It's extremely versatile, and we'll go through basic uses, as well as some problems and how to overcome them.

Some easing functions to try out:
Рекомендации по теме
Комментарии
Автор

Typo at the end! Should be b^(n+m) = b^n * b^m

Btw, support me for more videos:

simondev
Автор

Holy crap!
A long time ago, I was writing a multiplayer top-down shooter and I ran into a weird issue where the camera would start jittering like crazy, some kind of de-sync between the client and server. I never figured it out and just lost hope in the project, abandoning it.
Fast forward *15 years* and at the end of a video about interpolation, there's a quick side-note about a common mistake when interpolating positions. And, if memory serves, that is *exactly* what I did with the camera.

...Holy crap..!

tommysedin
Автор

i like the part where he said "It's lerping time!" and lerped all over the place

RineMarthen
Автор

Thanks, Simon. I'm lerping as a programmer but smoothing and shaping my path.

vincei
Автор

This is exactly what I needed for my game. Camera Log Zoom and Frame Rate independent tracking for aiming. Thank you so much, Simon! Subscribed.

doxed
Автор

Your smooth voice and professional animation and videos design gives your videos such nice aesthetics! Also love the knowledge you share with us

OlegV
Автор

This video needs to be waaayyy longer. I want more!

Henrix
Автор

I didn't check the math exactly but the last example when you are following the target, you are effectively solving a differential equation. The initial fix by multiplying by timestep should be forward Euler method. Using the exponential is an exact solution to the differential equation, hence the frame rate independence. However, it is exact solution only if the target is stationary(maybe also in the case of linear movement). Therefore it is still not frame rate independent but the error is much much lower.

tomasskrivan
Автор

That's an effective lesson, explaining all these concepts, functions, and implementations in such short time.

magic-window
Автор

There is a mistake at 8:07 IG b^(m+n ) = b^m * b^n not b^(m+n) = b^m + b^n.

oo
Автор

Every time I go to write I a comment you're ahead of me explaining what I know from intuition, but way better than I could. Then adding to that something I don't know.
brb gonna bing your videos.

Peterscraps
Автор

Nice linear/log zoom example! I was just staring at a linear fade in and thinking it didn't look good. I'll have to give log a try

GhostPandaFestival
Автор

I didn't know I needed this video until now, thanks!

ziggyharding
Автор

I've experienced 2 of the issues mentioned with deltaTime lerping and the camera zoom lerping problem. I found ways around both at the time but this video was very insightful and i've made some notes for these in the future as i'm sure i'll run into them again. I knew how lerp worked but i was always curious about smoothstep, it was funny cuz i've experimented with lerping between lerps so was a suprise that i was on the right track just didn't think of the sqrt. Great video Thanks!

Eddygeek
Автор

That bit at the end is especially brilliant! Thanks for the video!

spliter
Автор

I love these videos, covering basic concepts and tool sided in game development. I always learn new things and get a deeper understand of what I'm doing, and what I could do better. Thank you so much!

unfa
Автор

Interesting stuff. My favorite functions in Unity game development always has been lerp and slerp because they are easy to use and extremely useful in many situations. Also I love their names

Banaaani
Автор

I was lerping to change model heading, and the speed of the rotation was behaving differently in Unity editor and in build, and what you are talking about in the end was the exact problem I found.. and yes, I fed the delta time into the lerp to "solve" it. Thank you so much for the proper solution!

afriendlyfox
Автор

Hey Simon, I finally got around to implementing Lerps and I am very happy I kept your vid around. Helped a ton!

Kaeresh
Автор

Wow, I don't think I've seen such a useful video before, and it only was released a week or two ago. Major props, thanks for sharing

DarkSwordsman