Welcome,
< test subject name >

Name:
Pass:
Remember me

Apply to become a test subject.
I forgot my password

Donate!

Optimizing Maps

Optimizing your map is an important step to ensure an optimal experience for the player. Below are some of the best optimization techniques most applicable to Portal maps.

Leaks

Never ship a map with leaks, it causes any other optimization you do to be useless and forces the game to render the entire map every frame. Every map in the Source Engine (which Portal runs on) must be completely enclosed so the compiler can generate visibility leaves, which are used to calculate what can be seen from your current position. You will know your map has a leak if you see “***leaked***” in your compile log. When this happens, go to Map->Load Pointfile and click yes on the dialog that appears.

You will see a red line coming from one of your entities and exiting your map into the void somewhere. The space where the red line escapes must be sealed with a brush. Brush entities do not ‘block visibility’, the red line will pass through brush entities.

Hints

Hint brushes allow you to split leaves without placing a solid brush. The engine will draw the contents of the leaf you are in, as well as all the leaves that your leaf can possibly see (as calculated by vvis.exe during compile). You can define where you want leaves using hint brushes. A hint brush is simply a brush with sides where leaves should be formed textured with tools\toolshint and other faces textured with tools\toolsskip. They literally mean “visibility hint” and “skipped face”. One good use of hints is corners in hallways. You will have non-optimal corners if you do not help vvis.

Consider the room in the above photo. If you are standing at the entrance to the left hallway (eg. Top left) everything in the horizontal hallway will be rendered, even though you cannot see it.

You can prevent this with a hint wedge. Select the hint texture in the texture browser. Now select the wedge tool and create a wedge at the corner.

Now, texture the side facing the corner with tools\toolshint.

Remember that all hint faces should preferably ‘seal’ or bridge two surfaces together. As you can see in the picture above, the hint face connects both hallways and touches the tip of the corner.

Areaportals

Areaportals are very useful in portal because of all the doors and enclosed areas. An Areaportal is like a door. It is either open or closed, and when it is closed, nothing behind it is rendered (even if the player can see it). Areaportals allow you to completely ‘turn off’ an area the player hasn’t arrived in yet, or one the player has left. To create an areaportal, texture a brush (all sides) with tools\toolsareaportal. This brush must create a seal between two areas, just like brushes must seal the inside of the map from the void.

The above use of areaportals would cause an error, because although the portal seals the doorway it is in, there is another doorway which would allow visibility to pass between the areas. You can also link areaportals to doors. Simply set the Linked Door keyvalue to the name of a door, and ensure the door and the portal have the same initial state (open/closed). The engine will then automatically open the portal when a door opens, and close it once a door is done closing. There is another variation of an areaportal called an areaportal window.

Occluders

These rarely need to be used in Portal, but I’m mentioning them as they do have uses occasionally. Anything behind an occluder will be hit-tested before being drawn; this keeps a high-detail model in the same leaf as the player from being rendered from behind a wall. It does take time to make the calculations for an occluder, so only use them if they are necessary. How you texture it determines how it operates, using the occluder texture will cause models and materials to be affected, otherwise only models will be affected. To make an occluder, tie a brush entity to func_occluder.

Expensive Level Components

Some components of a level are expensive to render, and should be avoided/optimized as much as possible. Fire is a good example of something to try and turn off/stop rendering as soon as possible once it is unneeded.

Nodraw

A face textured with nodraw will not be... drawn. In fact, nodraw faces are deleted during compile (they will still seal visibility though). Any faces of your map that are inside the map that can never be seen should be nodraw. There is no need to mark faces facing towards the void as nodraw; the compiler does this for you.

Discuss this article in the forums!