Fixed variable frame rate in games: which is better and when?

After a long development of games, I was exposed to both variable frame rates (where you determine how much time has passed since the actor’s last tick and update) and fixed frame rates (where you work how much time has passed and select either a fixed amount of time or sleep mark, while the following window does not appear).

Which method is best for specific situations? Please consider:

  • Maintenance of various system specifications;
  • Ease of development / maintenance;
  • Ease of transfer;
  • The ultimate performance.
+6
frame-rate
source share
5 answers

Most 3D developers seem to prefer FPS variables: Quake, Doom, and Unreal engines scale up and down in system performance.

  • At least you have to compensate for a too fast frame rate (unlike 80 games launched in the 90s, too fast)
  • Your main loop should be time-parameterized, as long as it is not too long, a decent integrator such as RK4 should handle the physics normally. Some types of animation (keyframed sprites) can be a pain for parameterization. The network code should also be smart in order to avoid players with faster cars when shooting too many bullets, for example, but this kind of throttling will need to be done to compensate for the delay in any case (parameterization of the animation will also help to hide the network lag)
  • The time code will need to be changed for each platform, but this is a small localized change (although some systems make extremely accurate time difficult, Windows, Mac, Linux seem fine)
  • Frame rate provides maximum performance. Corrected frame rates allow for consistent performance, but never reach the maximum in all systems (which seems to be a trial traffic jam for any serious game).

If you are writing a 3D network game in which performance indicators are important, I have to say, bite a bullet and implement variable frame rates.

If this is a 2D puzzle game, you can probably get away with a fixed frame rate, perhaps slightly parameterized for super slow computers and next year's models.

+2
source share

I lean toward a model with a variable frame rate, but inside the system some systems are marked with a fixed time. This is fairly easy to do using a time saver. Physics is one system that runs best with a fixed time interval and is marked several times per frame, if necessary, to avoid loss of stability and maintain smooth simulation.

A bit of code to demonstrate battery usage:

const float STEP = 60.f / 1000.f; float accumulator = 0.f; void Update(float delta) { accumulator += delta; while(accumulator > STEP) { Simulate(STEP); accumulator -= STEP; } } 

This is not ideal, but it is the main idea - there are many ways to improve this model. Obviously, there are problems that need to be sorted when the input frame rate is indecently slow. However, the big advantage is that no matter how fast or slower the delta occurs, the simulation moves at a smooth speed during the “player’s time” - in this case, users will perceive any problems.

Actually, I don’t get into the scope of graphics and sound, but I don’t think that they are affected in the same way as physics, input and network code.

+4
source share

One of the options that I, as a user, would like to see more often is a dynamic change in the level of detail (in the broad sense, and not just in the technical sense), when the frames are changed outside the certification envelope. If you are rendering in 5FPS, turn off the bump display. If you're rendering at 90FPS, slightly increase the bells and whistles and give the user more beautiful images to reset your processor and GPU.

If everything is done correctly, the user should get the best experience from the game without going to the settings screen and configure himself, and you need to worry less, as a level designer, about the polygon to consider the same through different scenes.

Of course, I say this as a user of games, and not serious - I never tried to write a non-trivial game.

+3
source share

The main problem that I have encountered with variable-length time frames is floating-point accuracy, and variable time frames may surprise you with how they bite you.

If, for example, you add the frame time speed to a position and the frame time becomes very small and the position is quite large, your objects may slow down or stop because your entire delta has been lost due to accuracy, you can compensate for this with a separate battery, but it's a pain.

Fixed (or at least a lower bound on the frame length), allows you to control how many FP errors you need to consider.

+2
source share

My experience is quite limited to a few simple games (developed with SDL and C ++), but I found it pretty simple to implement a static frame rate. Do you work with 2d or 3d games? I assume that more complex 3D environments will benefit more from variable frame rates and that the difficulty will be greater.

0
source share

All Articles