Main
Tutorials











 

Map Optimization Part Two

Antiportals

Antiportals are the second major source of optimization, and are most useful in outdoor maps. Let's take a look at an example where antiportals would be useful.



In this case the pillar in the middle of the room is supposed to be hiding the meshes behind it, but as we can see this is not the case.



Now let's add an antiportal to the pillar. Antiportals can be any shape, as long as it is not concave (like a crescent moon shape). In other words, you should be able to draw a line from any point on the antiportal to any other point without leaving the antiportal. I like to stick with sheets, but simple primitives such as cubes and cylinders will work too. For antiportals to occlude, they must be at least touching the subtracted world space. Since it takes time for the engine to figure out what is hidden by the antiportal, you will want to keep them as large as you can and hiding as many meshes as you can. Using one inside a small pillar or one that only hides a 16 poly mesh would not be worth it, for instance. Let's set up a sheet inside the center pillar large enough to touch the subtracted space, then add it with the Add Antiportal button in the left toolbar.





As you can see in this composite picture, the antiportal is now hiding the meshes. In the editor antiportals only work in the 3d viewport when you have Realtime Preview activated (the joystick icon or 'p' for a keyboard shortcut). Antiportals are considered Volumes, so hiding Volumes through the View >> Show Volumes menu in the 3d viewport (or the 'o' button for a keyboard shortcut) will hide them as well. Toggling back and forth will let you see exactly what the antiportal is occluding.

Some situations where antiportals would be best is with terrain. Putting antiportals in large hills will hide everything behind it from the player. Any outdoor area where there is a large solid barrier is a perfect place to put an antiportal. Indoor maps can also use antiportals in addition to zoning for further optimization of mesh-heavy areas.

Collision

One thing that most new mappers overlook as far as optimization that can really affect performance is collision. The engine must make calculations for every mesh you, the other players, and projectiles touch, which in the case of meshes that have thousands of polygons can bring an otherwise smooth running level to a crawl. Let's take a look at an example of where changing collision properties would help.



It might not look like much, but when you consider that the meshes crammed in that alcove total 1486 polygons and that anything coming close to them will have to have collision calculations performed on them, too many areas like this would slow levels down. Most official static meshes already have simplified collision models on them, but even so we can help out by making it even simpler. First, let's turn off all the collision properties of the static meshes in that alcove. Open up their properties and set everything under the Collision tab to false.



Now to add a Blocking Volume to replace the collision. Put a cube inside the alcove and hit Add Volume >> Blocking Volume.





By default Blocking Volumes will not stop weapon fire, but it would be a little weird to have projectiles disappearing into the meshes, so let's open the Blocking Volume's properties and change it to stop weapon fire.



Now the Blocking Volume stops players and weapon fire, and as an added bonus players will not get caught on the corners of the static meshes, which is a major frustration among UT2003 players.

Sometimes leaving the collision properties of the meshes and Blocking Volumes alone would be better, as it will allow per-poly collision on the meshes for weapon fire which looks more realistic in some cases, but blocks the players from having complicated collision calculations making the level run faster, and still keeps them from getting stuck on the meshes. You should examine each situation to see which way would be best.

Fog

The last of the major optimization techniques is the use of Distance Fog. Distance fog was almost a requirement for older games to hide polygons that were far away while preventing them from suddenly popping into view. In the case of UT2003, it is not required but can be helpful in certain cases for making a level run faster.

The main thing to consider before using this technique is if it fits the theme of the map. Maps like BR-IceFields are a perfect example of where distance fog fits the theme of the map and provides atmosphere in addition to optimization. Even sunny outdoor maps can use it to provide a hazy effect in the distance.

To make distance fog, you must have a ZoneInfo in the zone you want it to be in, and set one of its properties.



One thing to keep in mind is that the fog will only appear if you are actually in the zone where it is set, so it's best to have the zones extend around corners or into buildings to prevent the fog from suddenly popping into view. Let's look at the properties for the fog itself and see where the optimization comes in.



Anything beyond the DistanceFogEnd value will not be rendered even if it is in the player's direct line of sight, simply because the fog is completely opaque at that point so the player will not see it anyway. Let's take a look at a bird's eye view of BR-IceFields to see this effect in action. I have raised the contrast in the picture so we can see it easier.



As you can see, towards the top of the picture static meshes and pieces of the terrain have started popping into view as they come within the outer distance. One thing you have to keep in mind is the color of the fog. To get a seamless effect in outdoor maps the fog must be the same color as the sky behind it. To see what happens if it is not, I have altered the color of the fog in BR-IceFields to illustrate the effect.



Mismatched fog will cause an unrealistic effect where everything can be seen popping into view, and as in the picture certain things can be seen "hovering" until the mesh it is sitting on comes into view. The easiest way to match the color of the fog to the skybox color is by using the 'Pick' button next to the ZoneInfo's DistanceFogColor property.



With that selected your cursor will turn into an eyedropper that you can use to pick a color in the 3d viewport. Clicking an area of the skybox behind the meshes will match the color.

That's it for the main techniques for map optimization. In the final pert of this tutorial I will explain some of the super-tweaks that are possible to squeeze every last frame out of your levels as well as reducing the file size. Let's go!

Continue to Part Three of this tutorial