Optimizing and Checking Your Map

From Valve Developer Community
Revision as of 21:58, 17 September 2005 by Geogriffith (talk | contribs) (Added mat_wireframe 2/3)
Jump to: navigation, search

Once you get your map built, you may want to check on its performance in the engine and see how you can optimize it (if you need to at all). This document describes some of developer features of the Source engine that let you evaluate performance.

Useful Console Commands

One useful feature of the console in Source: there is a help command! For a brief bit of help on any command, type help followed by the command text. Also, if you need any help finding a command, you can use the new find command. For example if you type find mat you will get a list of all the console commands with the text "mat" in the command text. For more information on using the console, see The Developer Console.

One other point: you will want to enable the console to access it in the game. Go to Options/Keyboard/Advanced... and there is a checkbox there to enable the console.

sv_cheats 0/1 This is the same as in Half-Life 1. It turns off and on the use of "cheat" console commands. You will need to activate cheats with sv_cheats 1 before using some of the commands listed below.
+showbudget The first thing you'll want to do is bind some key (or mouse button) to +showbudget What does +showbudget do? It displays a breakdown of how the engine is spending it's time drawing each frame on the screen. You'll see how long it's spending time drawing world brushes, entity brushes, prop models, displacement surfaces, 3d skybox, ropes, and other items. Now, with this information, you can optimize your map with good information. With what +showbudget shows you, you will know exactly what to optimize. Is your worldbrush load high? Then you know you need to simplify or improve vis blocking. Are static prop models overloading your view? Then you'll need to work on them, etc.

For a complete list of what the different categories mean, see Showbudget for more information.

mat_wireframe 0/1/2/3 This toggles off and on the display of wireframe detail for all brush and model objects in view. It is useful for showing you how your map's brushwork has been split up by the engine. It is also useful to show you just what is being drawn in any given view.

You will need to activate cheats with sv_cheats 1 to use this command. Mat_wireframe 2 and 3 give slightly different wireframe tracings, focusing on textures and brushwork, respectively.

mat_leafvis 0/1 This command turns off and on display of a wireframe box around the current leaf. For more information on using this command to debug visibility issues in your map, see Controlling Geometry Visibility and Compile Times.
mat_bumpmap 0/1 This console command toggles off and on the display of bumpmap effects by the engine. If you want to see how much impact on framerate bumpmap display has, toggle the effect on and off and view the changes (if any) with +showbudget. You will need to activate cheats with sv_cheats 1 to use this command.
mat_specular 0/1 Similar to the mat_bumpmap command, this toggles on and off specular reflection in the engine. You will need to activate cheats with sv_cheats 1 to use this command.
ent_messages_draw 0/1 Turns on and off display all entity input/output activity. As each entity is activated by input or output, the action is drawn at the entity's location, and a line drawn between entities as they target other entities. Can be useful for tracing and debugging entity actions in the game.
developer 1/2 Turns on debugging output to the screen listing all entity triggers and activity. Can be useful for tracing and debugging entity actions in the game.
cl_showfps 0/1/2 Shows and updates the frames per second that the frame rate is currently running at. (cl_showfps 2 is slower and much simpler to read)
impulse 81 Replaces your weapon with a set of reflective balls (models/shadertest/envballs.mdl) used for checking cubemaps. You will need to activate cheats with sv_cheats 1 to use this command.

Optimized Design

Now that you know how your map's performing, a few optimizations may be required. There are a few simple tricks for your map's layout that might help speed up your map.


The single worst thing you can do for your map's speed is create a giant skybox around your entire map. This renders useless faces and wastes speed and time. To fix this, think of a skybox not as a box, but as a roof. Use the buildings of your map as the walls, where possible. Long story short, only place skybox brushes where needed.

Dynamic Lights

They slow down your map and generally aren't used anyway. If you place a point_spotlight, make sure the No Dynamic Light flag is checked. Also, don't name any lights you don't need to. This causes the engine to treat each light specially, which slows down its rendering.


If you're going to use water, use it wisely. Make sure models that don't need to be in water aren't in water. Doing so causes the model to be rendered twice, which can slow down the map more as more of these cases appear. Another solution is to make the water cheap by using a water_lod_control entity. As with the skybox, only place water brushes where they are required.


Use as few brushes as you can, while not losing your desired detail. The biggest problem happens when you carve with a cylinder, resulting in too many small brushes in the wall. Use carve wisely, if at all. Also, use standard-size brushes -- 8, 16, 32, 64, 128, and so on. Not only are these easier to texture, they're easier for the engine and will help prevent leaks.


If you can see your whole map from one spot, there's not much you can do. Either redesign your map or take drastic measures to optimize it.

See Also