10hz Smoothness

posted in ROGRat
Published November 16, 2018
Advertisement

The old fixed timestep paradigm. Juicy stuff, and arguably the backbone of many a great gaming title  Until recently, I'd not bothered to implement it, instead preferring my own questionable potpourri of odds and ends, with maybe a little vertical blanking here and there.  I checked out DeWitter's game loop many moons ago but, in spite of it's virtues,  it wasn't what I needed at the time.

After being asked by a work-colleage-turned-indy-gamedev guy for a rundown on how it worked, what the point of it is and 'what the hell is this interpolation business?', I cobbled together a little demo.  In this video, everything is updated at a fixed timestep (60hz) however, only the colored bar is rendered with interpolated state.  At about the halfway mark, after throwing some white boxes onto the screen, I switch down to a 10hz update rate (after a brief pause).  Thanks to interpolation,, the colored bar retains most of it's smooth movement, even at `10hz.  The white boxes, with all their physics goodness, don't fare well at 10hz without interpolation.  I haven't implemented it there because I'm honestly not sure how..

https://www.youtube.com/watch?v=6SptavKHwew&feature=youtu.be

 

 

1 likes 3 comments

Comments

Septopus

It seems to me that the only way to achieve a variable frame rate with consistent physics would be to scale the physics forces per the measured frame rate, which seems incredibly unreliable to me.  Or decouple the physics loop from the rendering loop.  I'm also working on how to figure that out.  So, these are just wild guesses really. ;)

November 16, 2018 10:45 PM
Rutin

This is one of the main methods I've used on my custom engines. I will program in a fixed tick rate and keep the rendering at a variable rate. This of course forces you to use interpolation which isn't a problem and very easy to implement. I've personally never been a fan of variable time steps, but each to their own. :) 

November 16, 2018 11:01 PM
ROGRat

Thanks for your comments, guys.  Much appreciated! ?  I just realized that the video I uploaded was of the debug build, so it's choppier than it could have been.  Never mind, so long as people get the idea.

This is something I should have done years ago.  I'm really impressed with the playoff for the small amount of time invested.  It's not that I ever doubted it or thought that somehow my own hacks would be better, not at all.  I just get distracted with a squillion other things.

It's no surprise that the Gaffer implementation is nearly the de facto standard for game loops and if there was an established repertoire of programming patterns for game authorship, I'd reckon it'd be right up there. It's hard to fault and the frame rate gain is nothing to shrug at.

After going through the paces of adding a Gafferesque core loop and states, I can see why people either have difficulty putting it in their code or come away unsure as to whether they've done it correctly. Wrapping the whole shebang in a state structure makes for easier repeat visits.   I cheated a bit and used the structures and methods in the System.Numerics namespace which are conveniently SIMD/SSE enabled.

I've no doubt there are others, but I'm thinking of writing a top-down guide with all the nitty gritty details.  Speaking of which -- what's going on with the variable t I have seen in some bare-bone use-cases? :-)

November 17, 2018 12:03 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

10hz Smoothness

1480 views
Advertisement