TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Fixing the iterative damping interpolation in video games

127 点作者 ux大约 1 年前

11 条评论

markisus大约 1 年前
Unfortunately you cannot extend this approach much beyond this simple example if you are writing a physics simulation. There is no known closed form solution, for example, for the famous three body problem, so a some sort of numerical integration is absolutely required. At that point, you should just decouple the numerical integration timestep from the monitor refresh rate, or mandate a refresh rate that will be acceptable to the player.
评论 #40400568 未加载
nightowl_games大约 1 年前
Game dev here. Hardly any serious game developer uses lerp like that. I prefer a quadratic friction when I write custom friction, ie: a constant force away from velocity, and simply ensure it doesn&#x27;t go past the zero point. More controllable. Box2Ds friction uses something like v = v * 1&#x2F;(1+damping*delta_time), which is a good method as well.<p>Keep in mind it&#x27;s best practice to run your game logic at a constant update rate and render an interpolated state between the current and previous game logic frame, meaning that if your game logic is frame rate dependent, you can still run it smoothly on any monitor.
评论 #40403188 未加载
评论 #40402945 未加载
kibibu大约 1 年前
Alternatively, you could fix your timestep, decoupling your physics from your display refresh entirely.<p><a href="https:&#x2F;&#x2F;gafferongames.com&#x2F;post&#x2F;fix_your_timestep&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gafferongames.com&#x2F;post&#x2F;fix_your_timestep&#x2F;</a>
评论 #40404405 未加载
评论 #40400571 未加载
omoikane大约 1 年前
All the frame rates in this post appears to refer to physics frame rates, but Godot makes the distinction between physics and display frame rates, and have separate callbacks for each:<p><a href="https:&#x2F;&#x2F;docs.godotengine.org&#x2F;en&#x2F;stable&#x2F;tutorials&#x2F;best_practices&#x2F;godot_notifications.html#process-vs-physics-process-vs-input" rel="nofollow">https:&#x2F;&#x2F;docs.godotengine.org&#x2F;en&#x2F;stable&#x2F;tutorials&#x2F;best_practi...</a><p>Because physics frame rate is fixed (configured under project settings), I suspect developers would be able to get away with using the common lerp() formula and not having to worry about varying (display) frame rates.
评论 #40411261 未加载
jprete大约 1 年前
I think the real problem with the OP&#x27;s straw-proposal interpolation method is that it&#x27;s stateless and doesn&#x27;t need to be. I would instead record the start position, then interpolate along a function F(t) to the end position. F(0)=0, F(1)=1, F&#x27;(0)=F&#x27;(1)=0 just so the ends aren&#x27;t jerky. The curve can even overshoot 1 to give the animation some bounce.<p>I&#x27;m sure somewhere on the Internet somebody&#x27;s written down some good choices of curve; hopefully someone else knows what to search for.<p>(I don&#x27;t know what to do if another change interrupts the first but it&#x27;s a rare case and can probably be handled imperfectly.)
评论 #40402709 未加载
评论 #40404846 未加载
BoingBoomTschak大约 1 年前
Don&#x27;t most modern video games run a physics thread at fixed rate in addition to the rendering one?<p>I remember Quake 3 still having that issue, but that was in &#x27;99...
jayd16大约 1 年前
Wouldn&#x27;t you just want to sample a normalized curve and apply that? What is the use case where you want to use this iterative call, care about frame accuracy, but can&#x27;t afford curve data?<p>With the explicit curve you have more control in the exact damping, too.
评论 #40401427 未加载
refulgentis大约 1 年前
I was bit confused how a formula that depends on a constant frame rate works with variable refresh rate. Then the author commented that you don&#x27;t need to calculate the quantity that depends on frame rate in code. <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40401211">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40401211</a><p>I&#x27;m really lost, but alas have ~0 experience with 3D about 15 years into a career.<p>Ignoring variable frame rate: 1. Doesn&#x27;t the frame rate depend on the display hardware?<p>2. Can you know the frame rate at runtime?<p>Variable frame rate: 3. What quantity do you use for frame rate for variable frame rates?
评论 #40435942 未加载
Ono-Sendai大约 1 年前
Proposed solution is too expensive with ln and exp calls.
评论 #40401211 未加载
chrisjj大约 1 年前
Nice, but ...<p>&gt; So there we have it, the perfect formula, frame rate agnostic ,<p>... worth noting what happens on a frame time spike.
评论 #40398575 未加载
ncruces大约 1 年前
Now write the formula in terms of expm1 for numerical stability, and express the constant in terms of “half life” measured in seconds to make it intuitive instead of magical.
评论 #40402505 未加载
评论 #40401159 未加载