News for hackers. Stuff that matters.
Re:Fixed Timestep Without Interpolation by thegeomaster on Friday October 18, 2024 @08:57AM (#41879016)
One important approach is missing: extrapolation.

Usually, your entities all have velocities, which you can use to extrapolate from the last simulated state to the current one (after <dt time has passed). For things like visual effects, you'd have to have a custom extrapolate implementation, which is not really different than a custom interpolate implementation that you need for interpolation.

This eliminates the lag issue, and at anywhere close to 60FPS, looks perfectly fine. It will look strange at very low framerates, but at that point, you can just automatically switch it off.

You do need a way to extrapolate game state, which is slightly painful, but the author's proposed solution has big drawbacks (which he hints at). Since it touches all game state each frame (even though it's "just" a memcpy), it completely changes the performance characteristics of your main loop.

Without this, the complexity of your game step is linear in the number of updated or rendered entities, so you can add large amounts of additional state at any time, as long as only a small part of it will be visible/relevant to update each frame.

With the author's approach, your step complexity is linear in the state size. You basically have an additional write for all state, which gives you a very restrictive upper limit. It's not just AAA games - as soon as you add a particle system, you've created a great many entities which you now need to memcpy every frame.

The scalable solution to this complication is copy-on-write, which is more complexity... or, bite the bullet, write that extrapolation function, and enjoy your freedom to introduce crazy particles, physics, MMO world state, or whatever you want! At real-world framerates, it will look no different.

Re:Fixed Timestep Without Interpolation by jakubtomsu on Friday October 18, 2024 @09:53AM (#41879491)
Extrapolation has some very serious drawbacks in action games which make it unusable though. You cannot just move entities forward in time by velocity*delta, because that ignores all collisions with the world. So you end up with a lot of weird jitter and ugly effects like that. And once you start adding support for things like collision while extrapolating, why not just tick the entire game;)
Re:Fixed Timestep Without Interpolation by jakubtomsu on Friday October 18, 2024 @09:54AM (#41879496)
(collisions are by far not the only issue here, it's just the first one you run into)
Re:Fixed Timestep Without Interpolation by jayd16 on Friday October 18, 2024 @12:46PM (#41881145)
> why not just tick the entire game

In a multiplayer scenario, you might not have enough information to tick the entire game. You'll probably want to extrapolate input from other users, at least.

Re:Fixed Timestep Without Interpolation by meheleventyone on Friday October 18, 2024 @04:31PM (#41883194)
On the contrary in multiplayer extrapolation is the last thing you want to do because the time to correction is long and the prediction is really coarse. It essentially results in a lot of corrections, applied late which looks and feels awful.
Re:Fixed Timestep Without Interpolation by dyarosla on Friday October 18, 2024 @11:40AM (#41880431)
Extrapolation is one of those ideas that’s not actually used in practice- at least I’ve yet to see it used in any games in any meaningful capacity.

It’s just far too complicated and requires custom logic while resulting in worse results than more straightforward options. Even for multiplayer games the “extrapolation” is often done by repeating input states and running the regular game loop.

I also wouldn’t equivocate the interpolation approach with extrapolation. With interpolation you interpolate between two valid states. With extrapolation you produce a potentially invalid state (ie a character that’s inside of a wall). The only work around for the latter issue is to perform a full game tick - at which point you’re no longer doing extrapolation.

Re:Fixed Timestep Without Interpolation by jayd16 on Friday October 18, 2024 @12:34PM (#41881011)
> Extrapolation is one of those ideas that’s not actually used in practice

This is how VR frame doubling works, no? "Timewarp"/"Spacewarm"

Also I would think that a lot of netcode would be considered extrapolation. You'd extrapolate a peer's input or velocity (and perhaps clean it up with further local simulation) and then deal with mis-prediction when changes are replicated.

Re:Fixed Timestep Without Interpolation by dyarosla on Friday October 18, 2024 @03:30PM (#41882663)
For the former, Timewarp is used at an OS level to perturb the visibly rendered quad to match the display time orientation. There’s no extrapolation: the rendered frame is simply adjusted to account for the change in headset orientation.

For the latter, as I mentioned, the extrapolation is not on velocity: you still compute regular game ticks but by holding the input constant. This is quite different from extrapolating velocities.

Re:Fixed Timestep Without Interpolation by jayd16 on Friday October 18, 2024 @04:12PM (#41883033)
Spacewarp takes the motion vectors and depth buffer and generates new frames from the extrapolated motion. Its detailed here. https://developers.meta.com/horizon/blog/introducing-applica...

> For the latter, as I mentioned, the extrapolation is not on velocity: you still compute regular game ticks but by holding the input constant. This is quite different from extrapolating velocities.

Replicating velocity is fairly common. Unreal's character movement replicates velocity and not inputs. I would personally argue that even doing a full game tick with replicated velocities is extrapolation. I'm not sure what the distinction would be or what counts as a full tick with error correction vs local extrapolation per tick with error correction.

Re:Fixed Timestep Without Interpolation by dyarosla on Friday October 18, 2024 @06:37PM (#41884125)
I agree- what’s the difference between error correction and a full tick? At what point do you draw the line on error correction?

Extrapolation is often used to mean extrapolating values without error correction, at which point the results are less than stellar.

Spacewarp is, like Timewarp, a way to match the render frame time on a headset but by creating a warp of the output image; ill concede that this is technically extrapolation but is far away from whats generally referred to in describing updating entity values in game loops.