Tuesday, June 14, 2011

Increasing Frame Rate in the Blender Game Engine

The list below is intended to be a guide to getting the best frame rate possible in the Blender Game engine (if not the best looking game). Some suggestions will yield large frame rate increases, while others will yield smaller increases. Different computers, graphics cards, operating systems and versions of Blender will yield different results. This is a work progress. I will be posting some things that are absolutely true, and others that require verification -these will italicized and marked with question marks. I invite comments, debate, & collaboration.

General Notes

  • The suggestions in this post will increase your frame rate, and in some cases lower the quality of the graphics in your game. Consider creating two versions of your game - a walk around and admire the view version (maxed out graphics), and a maxed out frame rate version. Commercial games offer this flexibility.
Your Computer
  • Update your graphics card's drivers.
  • If your video card supports Anti-Aliasing, turning it off will increase your frame rate dramatically.

Game Engine Modes & General Set Up
  • Texture Face and Multi-Texture modes are faster than GLSL.
  • Use "Display Lists" (Blender Game - Render (camera icon) - Performance) for larger scenes, but not for smaller scenes. Experiment turning this on and off, and note the frame rate difference, if any.
  • Use "Frame Rate" (ticked by default). (Blender Game - Render (camera icon) - Performance).
Objects and Geometry
  • Model objects with as few faces as possible, and as many quads as possible.
  • Remove all unnecessary faces (internal faces, backs of cabinets against walls etc.).
  • Use appropriate face counts - Small or less significant props should have fewer faces than larger or more significant props. These two factors are exclusive of each other - it is possible to have large, insignificant props, such as distant buildings, and small significant props, such as weapons that will be seen a lot.
  • Join objects when possible (objects without physics etc.). For example, all objects made of the same material, or all of the buildings in a scene.
Shaders & Nodes
  • Use Lambert and Phong.
  • Turn specularity off in the material panel if it is not needed.
  • Disable use alpha if it is not needed - Texture Panel - Image Sampling - Alpha (untick).
  • Use mix, add, subtract or multiply for texture blending.
  • ? Use nodes sparingly. ?
  • Disabling Shaders and Extra Textures in GLSL mode (Game Engine - Render -Shading) will increase your frame rate dramatically.
  • Textures should be sized in powers of two (16, 32, 64, 128, 256, 512, 1024, 2048 px etc). 
  • ? Square textures perform best. ?
  • Small textures perform best.
  • Merge textures when possible - Diffuse and AO maps for example, or all of your plant, door or window textures.
  • Reuse textures in your scene, so that the game engine has to dynamically load as few textures as possible.
  • Use tiling textures to increase the appearance of detail without using large texture maps.
  • Use normal maps (in GLSL) mode to increase the appearance of detailed geometry on lower polygon meshes. 
  • Use Mip Maps.
  • Use Alpha Channel textures and transparency sparingly.
  • Below, some common map types, listed in order from highest to lowest frame rate consumption. Worst to best.
    • Normal
    • Specular
    • Fake reflection (abstract image mapped to "Reflect", "Color")
    • Emit
    • Grunge/decals - Transparent Bbackground PNG
    • AO (Black & hhite image set to "color", "multiply")
    • Diffuse
This is based on an informal survey conducted on Blender artists, and is certainly open for debate.
Blender Artists Texture Map Thread
  • Use as few lights as possible.
  • Disable specularity in the Lamp Panel if possible.
  • Bake lighting if possible.
  • Bake shadows when possible, as opposed to using buffer shadows.
  • Set lamps to only affect objects in specific layers (ordinary lamps and buffer shadow spots).
  • Use scripts to move lights around with the player. Think of it as a house which turns lights on and off as you pass through various rooms.
  • Use rigid body and dynamic objects sparingly. Use scripts and logic to add and remove them from them your scene as necessary.
  • Use bounding boxes to simply physics calculations.
  • Remove collision from any object or mesh on which it is not required. There are two places to do this:
    • In the physics panel, set the physics type to "No Collision".
    • In edit mode:  Mesh panel - Texture Face - No Collision (use copy mode to untick for all faces).
    • ? Set gravity to 9.8 (default). ?
    • Use the Convex Hull bounding box type sparingly.
Special Effects & Filters
  • Filters such as real-time depth-of-field, screen space ambient occlusion, bloom lighting etc.can be nice looking, but are frame rate intensive. Consider alternatives (such as baking AO) when frame rate is an issue.
  • Video Texture scripts, used for real time mirrors and other effects are frame rate intensive. Use alternatives when possible.
  • Mist - turn it off when possible.
  • Use level of detail objects and scripts when possible in large scenes.
  • Use Occluding objects when possible.
Animation and F-Curves (IPO curves)

Bibliography & Sources

Bender Artists.org