Jump to content
  • Advertisement
Sign in to follow this  
cozman

smoothing measure of FPS/timeDelta

This topic is 4841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently measuring the time between frames and using it to update the display. For example, in a simple spinning cube demo using my library I adjust all of the rotation variables by a constant multiplied by my timeDelta:
xRot += 30*dt;
yRot += 40*dt;
zRot += 50*dt;
The trouble is that roughly every 0.5 seconds, the cube jumps a little bit. The application is running at 800fps, but it seems like there are small hiccups. I've done a bit of searching, and I've gathered essentially what the problem is. When the FPS is this high, the smallest jump in FPS can make things look choppy. What I'm wondering is what my options are to solve this? I'd like to have a value that I can use in a manner similar to a timeDelta, but is reasonably stable. The only option I've thought of so far is to calculate FPS based on a number of frames so that it is an average, and using the inverse of FPS. Although this would certainly give smoother results, it doesn't seem like the best option. Note that I'm looking for a general solution, not talking about fixed-step physics or anything like that. This question is purely what techniques people use to "smooth" their timeDelta values.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Well I'm not too sure because I have yet to have a computer that ever ran anything at 800fps, but I would say just buffer, and average the last 2 to 5 values, I would think that this would give smoother results. The more you average, the smoother, though less accurate your results will be.

So like have an array.


float dtArr[5];

dtArr[arrCounter] = realdt;

arrCounter++;

if (arrCounter >4)
{
arrCounter=0;
}

dt = (dtArr[0] + dtArr[1] + dtArr[2] + dtArr[3] + dtArr[4])/5

Share this post


Link to post
Share on other sites
That is one of the options I'd been considering, I know that by averaging I can smooth FPS/timeDelta, but the loss in accuracy is undesirable. I was wondering if there are any techniques that are common that give a better trade-off than averaging the last N frames.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
While I'm sure there's some nifty mathematical trick to smooth it, I too just increase the 'frames per second' to 'frames per X seconds divded by X'.

One thing you might consider is some sort of non-linear proportion between the FPS and the cube's rotation. Make the cube accelerate just as much when the FPS jumps from 5 to 6 as it does from say... 200 to 240.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
While I'm sure there's some nifty mathematical trick to smooth it, I too just increase the 'frames per second' to 'frames per X seconds divded by X'.

One thing you might consider is some sort of non-linear proportion between the FPS and the cube's rotation. Make the cube accelerate just as much when the FPS jumps from 5 to 6 as it does from say... 200 to 240.


oops, that was me.

Share this post


Link to post
Share on other sites
The more I look over it the more it seems that an average would be the best way to eliminate skips, and so far it seems like what others are doing.. I'll probably add smoothing that stores a sum of N frames and averages them.

Thanks for the help Telastyn and other AP, and if anybody has any more suggestions I'd still be up to hearing them.

Share this post


Link to post
Share on other sites
'frames per X seconds divded by X' = 1 ?

There could be a lot of reasons for the skip. I know I’m trying to get rid of the same thing in my app.

Ask your self these questions.
Is xRot an angle? Can it be over 360?
Are you resetting this angle with out taking into account the over shoot.?

Where are you getting dt from? TimerGetTime, TickCount, QueryPerformanceCounter. All have pro’s and cons QueryPerformanceCounter has a known bugs.

This page tells you all about it in a rather complex way.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by bobason456
'frames per X seconds divded by X' = 1 ?
.


(frames per X seconds) / X

so let's say you're app is running at about 100fps, and X is 10
frames per X seconds ~= 1000
X = 10

(frames per X seconds) / X = 100

Actually I've come up with a decent idea of what I'm going to do, this question was actually for my open source game library (Photon, see my sig). I am going to have a method to set what sort of timeDelta should be used, giving the user an option between the actual amount of elapsedTime, elapsedTime over X seconds, or a fixed step.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!