Frame Rate Optimization

TIP Excerpt and partially modified from Game Studio Manual A7: Frame Rate Optimization

The frame rate is the number of frames rendered per second (fps), and determines the 'smoothness' of game play. It is dependent on five factors:

  1. The speed of the engine;
  2. The speed of the video drivers;
  3. The hardware performance;
  4. The complexity of the running scripts and the rendered scene;
  5. and an artificial delay for keeping the frame rate in sync with the monitor.
However, the frame rate is not just determined by the sum of the above factors - they can influence each other. The fps contribution of certain level elements can be seen in the [F4] panel in ms per frame. The additional delay added by the system for synchronizing the frame rate is reflected by the 'screen refresh' time. In some cases it can be larger than the real rendering time by the engine and hardware, especially in fullscreen mode in which the frame rate is limited by the monitor frequency (mostly 60 Hz on LCD screens and 70..80 Hz on CRT monitors).

Updates and fps

Engine updates normally render faster than their predecessors - and no update ever was slower. Nevertheless, whenever a new engine update comes out or a new video driver is released, some users complain about having 'less fps' than before. Why is that?

Every subtle change in the system can affect the frame rate in a different way, depending on hardware and software components. So it's normal that even when a newer engine renders faster on most systems, it can be slower on a few. Video drivers, especially by nVidia, often use optimizations for performing better with benchmarks. Those optimizations also change with every driver release and with every DirectX version the engine uses. In the last time nVidia tended to remove those optimizations from their drivers due to their side effects.

Even if you think that the new update runs 'slower' on your PC than it's predecessor, use it if you want to distribute your game. It's the end user's frame rate that matters.

TIP ParaEngine tries to maintain an ideal rendering frame rate which is 30 FPS by default.

Monitor frequency and fps

In fullscreen mode, DirectX keeps the frame rate always in sync with the monitor frequency between 60 and 80 Hz in order to avoid tearing artifacts. The screen refresh is artificially delayed for matching the time when the monitor has finished its video cycle. Thus you'll never get a higher frame rate than your monitor can display. Your frame rate will be an integer division of the monitor frequency (such as 60, 30, 20, or 15 Hz when the monitor frequency is 60 Hz). When the frame rate is close to the monitor frequency, a small change of the rendering time will cause the frame rate to suddenly jump from 60 to 30 fps or vice versa.

Some tips for increasing the frame rate in your games

  • Avoid using a big model for a level. When the engine renders the whole level as a single model, it can't use it's scene management, and renders even the parts of the level that are not visible. That will result in a very bad frame rate.
  • TIP Create Portals for large indoor environments with several rooms.
  • TIP ParaEngine will automatically do instancing if there many static mesh of the same type.
  • Avoid using reflection surfaces especially in outdoor environment. And disable reflections on objects like ocean, water, or reflective surfaces will greatly improve frame rate
  • Run with lower resolution, this will reduce fill rate.
  • A medium number of medium sized meshes renders faster than a huge number of small meshes, or a small number of huge meshes.
  • Deactivate the mouse if you don't need it .
  • Reduce the number of sounds audible at the same time. Some sound cards without hardware mixer reduce the frame rate remarkably when many sounds play simultaneously.
  • TIP Text rendering can reduce the frame rate remarkably. Avoid using too many fonts or too many text on screen.
  • TIP The smaller the clipping range (camera.clip_far), the faster the rendering especially in outdoor levels. Activate fog if you want to cover the clipping border.
  • TIP Cheap 3D cards work best with 256x256 texture sizes. The bigger the texture, the slower the rendering.
  • Terrain renders faster than models - especially when it's chunked. Do not use models for terrain.
  • With today's 3D hardware, the best model size is in the range of 500..1500 polygons. If possible, split bigger models in several parts. The best block mesh size is somewhat smaller, about 100..500 polygons.
  • TIP When constructing a model, have it's origin as close to it's center as possible. Models with bad placed origins require more space in the scene management tree, and cause slower rendering.
  • TIP Nonanimated models render faster than animated models. Use meshname_v.x when you just want a model to swing like in the wind. Such animation is done in hardward shader and is way faster than skeleton animations.
  • Vertex animation is faster than bones animation.
  • Nontransparent or overlay textures are faster than transparent or alpha channel textures, especially when you have many entities in the level.
  • The AABB collision detection is faster than the OBB detection.
  • sky models and sky domes have a great fill rate, be aware of them.
  • TIP Use LOD models whenever possible, especially in high resolution characters and outdoor models. For characters, we usually have 3 LOD, such as 500, 1500, 3500.
  • DDS texture with Mipmapping increases the frame rate. Always create mipmaps for model and terrain skins using dds format.
  • Last but not least: newer engine versions are faster than older engine versions. Always uses the latest engine update.

Frame rate controller

ParaEngine uses different frame rate controller for rendering, physics, io, scripting, etc. ParaEngine tries to maintain an ideal rendering frame rate which is 30 FPS by default.

The main reason for stuttering is a coarse PC scheduler resolution that leads to inaccurate task start times, especially when many tasks are running on a particular PC. This problem can be avoided by limiting the frame rate not only with fps_max that just gives task time back to the Windows task scheduler, but by really burning CPU cycles in some or the other way. Fortunately, this is easily done. If your game experiences stuttering, just place some more details in your levels for avoiding a too-high frame rate.

Topic revision: r1 - 2009-01-31 - LiXizhi
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback