Map Optimization Part One
One of the biggest problems people have with making maps is getting them to run smoothly even on low end machines. In this tutorial I will detail the main techniques for map optimization as well as lesser known tricks for getting them to run and load faster. Ready go!
Zoning should be your primary means of map optimization, although in maps set mainly outdoors this will not always be possible. Zoning helps the engine by sectioning off the level, and any area that the player cannot see at all will not even be considered for rendering. Let's take a look at a typical example of something you would see in a map, two rooms with static meshes separated by a doorway.
If you were in the room opposite the static meshes, you wouldn't expect any of them to be rendered through the wall, but unlike UT99, BSP no longer occludes, so without optimization everything on the other side will be rendered. In the following picture you can see the doorway highlighted in green, and the static meshes are being rendered even though the player cannot see them in the normal rendering mode.
Using the wireframe mode in-game is a great way to tell exactly what the engine is trying to render and what needs more optimization. To see your level in this mode, start a game and pull down the console (The ~ key) and type "rmode 1" without the quotes. To get back to normal, use "rmode 5".
Now let's zone off our level to see what effect it has and exactly how it works. Make a sheet that cuts our doorway in half (overlapping a bit is fine and in some cases will prevent bsp errors), and press the Add Special Button. In the drop-down list choose Zone Portal and hit Ok.
Now hit Rebuild All, and our level will be separated into two zones.
Hitting the Zone/Portal button will let us see that it worked.
Ok, our level is zoned! Now to see exactly what effect this has in-game. Looking at the wall with the zone portal just out of view, we can see that nothing in the other zone is being rendered.
If we turn slightly so that the zone portal is in view, we can see that the bsp in the other zone is being rendered.
All of the static meshes are still hidden, but as we move across the room any mesh that sticks into the zone portal's view is rendered.
As you can see with the mesh on the left, even if just a fraction of the mesh is sticking into view the entire thing is rendered. Static meshes aren't broken into pieces for rendering, so if any of it is rendered the entire thing will be. If you try to hide polys by sticking the mesh halfway into a wall for instance, the polys that the player cannot see will still be rendered and will still affect framerate.
The maximum number of zones that UT2k3 can support in a level is 64, so there is plenty of room to divide your level into smaller sections. Zone portals should be kept as small as possible, preferably in doorways and at the end of halls. Wide open spaces should not be zoned. For a good example of zoning, look at some of the official indoor maps in the editor, such as this pic of DM-DE-Ironic.
Sometimes when you have meshes sticking partially into walls the engine will confuse which zone it belongs to, and might render it in a zone you didn't intend it to. Let's take a look at an example in the editor, where I have placed a row of static meshes in the wall of the top room, almost sticking into the bottom room.
I only want the meshes to be rendered when the player can see them in the top room, but as you can see in the following picture they are being rendered when the player is in the bottom room, even though they cannot actually see them.
The engine does not know for sure what zone the meshes are in, so it renders them as though they belonged to both. To fix this problem, we can "force" the meshes to be in a certain zone. Place an Info >> ZoneInfo in both rooms, then open up the properties of the one in the top room, and set an Events >> Tag.
Now open up the properties of the problem meshes, and put that Tag in their Display >> ForcedVisibilityZoneTag box.
Now let's take a look in-game.
Now it works! Using this technique for static mesh zoning will help increase framerate by not rendering meshes when they're not supposed to be. That's it for zoning. In part two of this tutorial we will look at a few more of the main techniques for optimization, particularly for outdoor maps. Let's go!
Continue to Part Two of this tutorial