Friday, May 13, 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 be italicized and marked with question marks. I invite comments, debate, & collaboration.

Blender.org Discussion Thread

If you wish to learn more about a specific technique, link to this thread and ask for help on BlenderArtists.org

Direct links to this thread:
Link Text: Increasing Frame Rate in the Blender Game Engine
Link URL: http://3dmedieval.blogspot.com/2011/05/increasing-frame-rate-in-blender-game.html

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 with 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).
  • Use a few Scenes to split up large levels. For example, create a new scene when you enter a room with a closed door in a house, or enter a cave.
The Camera
  • Set your camera clipping as low as you can (Camera panel - Clipping). Mist can help hide the effects of a sudden cut off, but will reduce frame rate. 
World
  • Mist - Use of mist will decrease frame rate.
  • Use Level of Detail (LOD) objects and associated scripts when possible in large scenes.
  • Use Occlusion Culling on larger scenes when possible. Be aware that if used improperly, Occlusion Culling will increase your frame rate.
Objects, Meshes & Geometry
  • Model objects with as few faces 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 frequently.
Materials & Shaders
  • Use Lambert diffuse and Phong specular. These shaders are fastest.
  • Turn specularity to zero in the material panel if it is not needed. Zero = off.
  • Disable use alpha if it is not needed - Texture Panel - Image Sampling - Alpha (untick). For some reason, this is ticked automatically.
  • Use mix, add, subtract or multiply for texture blending. These blending modes are fastest.
  • ? Use nodes sparingly. ?
  • Disabling Shaders and Extra Textures in GLSL mode (Game Engine - Render -Shading) will increase your frame rate dramatically.
Textures
  • 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. 
  • Arrange as many textures on one sheet as possible (texture atlasing). It's like continuing to read from one page, as opposed to picking up several sheets of paper and reading a bit from each.
  • Use Alpha Channel textures and transparency sparingly.
  • The .DDS (Direct Draw Surface) texture format may  have some benefits on game speed, and certainly on load times. For more information, see the bibliography, below. .DDS textures are used in games such as The Elder Scrolls IV, Oblivion.
Lights
  • 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 spot lights with buffer shadows.
  • Set lamps to only affect objects in specific layers (ordinary lamps and buffer shadow spots).
Physics
  • Use rigid body and dynamic objects sparingly. Use scripts and logic to add and remove them from  your scene as necessary.
  • Use bounding boxes to simplify 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. Copy Mode is currently an add-on).
    • ? 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.
Animation and F-Curves (IPO curves) 
  • Place holder
Logic
  • Avoid Always Sensors set to True Pulse mode with a frequency of  0 when possible.
  • Radar Sensors perform slowly.
  • Near Sensors perform slowly.
  • Rather than running logic for every object of a specific type, loop through a list of objects and run the logic for them.  More information on this technique can be found here: SolarLune's Logic Speed Increase Technique
  • Use states with a logic culling system (for example, enemies near the player use full AI, while those out of view can idle).
Python
  • Place holder

Bibliography & Reources


GLSL Materials

2 comments:

  1. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.
    youtube html5 player| html5 converter

    ReplyDelete