[TIP] Leaks, Hints and Areaportals

Oct 25, 2007
219
690
Part 1-- **** leaked ****

Leaks are bad. In fact, they are one of the worst things that can happen to a good map. However, the good news is that 99% of the time, they are easily fixed!

What are leaks and how do leaks happen?

Good question. For a TF2 (or HL2 or CS:S) map to work properly, it needs to be sealed. Think of the map as being airtight, and there's a vaccuum of space outside the walls of your map. If there's a leak, all the good stuff will be sucked out into outer space. This is bad.

leak1.jpg

Here is what a leak looks like in the game. You can tell because of all the distorted textures around it.

Leaks usually happen when you have a small hole that fails to seal the map, or an entity that's been misplaced outside of the map. Other things can also cause leaks, like bad brushes, or trying to seal a map using entities and wrong textures.

I don't see a leak, how do I know I have one?
Check the log when you compiles the map (using the run map command). Here is an example of what to look for:

materialPath: z:\program files\steam\steamapps\xxxx\team fortress 2\tf\materials
Loading Z:\dox\maps\testmaps\visleaf.vmf
fixing up env_cubemap materials on brush sides...
0...1...2...3...4...5...6...7...8...9...10**** leaked ****
Entity light (0.00 16.00 32.00) leaked!


I've got a leak! What do I do?
Fortunately, Hammer has a few tools to help out. First the loadpoint tool, located in the map menu. The loadpoint will create a path from one entity to your leak. Just follow the red line.

leak2.jpg

In this case, my hole is pretty big and obvious. Sometimes a leak can be very, very small.

Another tool is the check for problems option under the map menu. It will tell you if you have any bad brushes.

Can I still play my map with a leak?
Technically, yes. However a lot of entities don't work (like water and lights). Also there was no VIS optimization (which we'll speak about shortly), so that map will be performming poorly. You may also get a lot of visual glitches from outer space.

Should I construct a large, hollow box around my map to seal it?
It's an option, but not a very good option. This is because the game still needs to not only render this giant box, but also any outside textures that you normally won't see(the game automatically ignores any textures that face outside of the map). Both your compiling time and playing performance will be detrimentally affected by this big box. This should be a tool of last resort.
 
Last edited:
Oct 25, 2007
219
690
Part 2 -HINT Brushes (and SKIP brushes)

A foreword on VISLEAFS

Let me try to clarify what exactly we're trying to optimize here. When you compile a map, one of the three tools used is VVIS (or sometimes just called VIS). VIS breaks down the map into viewable areas to help with the performance of playing the map. These viewable areas are called leafs (or visleafs). When you approach a corner in a map, VIS creates a guide when to start rendering the objects around the corner, depending on which VISLEAF you are currently in. Without VIS, your computer would try and render everthing within your area, whether you can see it or not.

One large VISLEAF is better that a whole bunch of small VISLEAFS. This is what we sometimes have to help VIS accomplish, is reducing some of the excessive VISLEAFS created.

To do this, we use the HINT brush (and it's companion, the SKIP brush).

First a quick map as an example.

I'm going to make a small room with stuff that'll give VIS a headache. Here's the map:
hint1.jpg


The wedges and cylinders will force VIS to create excessive amounts of leafs. Let's run this map and see what VVIS gives us:

2 threads
reading z:\demonic dox\maps\testmaps\visleaf.bsp
reading z:\demonic dox\maps\testmaps\visleaf.prt
28 portalclusters
42 numportals

0...1...2...3...4...5...6...7...8...9...100...1...2...3...4...5...6...7...8...9...10Optimized: 0 visible clusters (0.00%)
Total clusters visible: 584
Average clusters visible: 20
Building PAS...
Average clusters audible: 27
visdatasize:454 compressed from 448

writing z:\demonic dox\maps\testmaps\visleaf.bsp
0 seconds elapsed

Now for one room that could fit one large leaf, we've suddenly gotten a whole mess of visible clusters. Not very efficient. :(

I'll run the map, and using the console, I'll type MAT_LEAFVIS 1. This shows me the frames of my different leafs. I see a lot of little triangular leafs in the corridor. It may help to clear to corridor. I also see a ton around the cylinders.

Okay, now I'm going to help VIS. First, I realize that those two cylinders and creating way too much work for VIS. I'm going to cheat and make them into func_detail entities. Func_detail get ignored by VIS, however, they won't seal a map. In this case, making them into Func_detail is perfect.

Next, I'm going to create two HINT brushes. These will run down the corridor and should help VIS break down visibility. To make a HINT brush, first, let select a SKIP texture (I'll explain why in a second). I make the brushes as thin as I can (1 unit thick), and now I texture only one side with the HINT texture. Let me make this clear, a hint brush only uses one (or sometimes two sides) with the HINT texture. Please don't make a cube with all six sides having a hint texture, it won't help as much as you might think. Anyway this is how the map looks with the hint brushes:
hint2.jpg


Alright now that I've optimized this map, I'm going to compile. Let's see what VIS says now.

2 threads
reading z:\demonic dox\maps\testmaps\visleaf.bsp
reading z:\demonic dox\maps\testmaps\visleaf.prt
10 portalclusters
13 numportals

0...1...2...3...4...5...6...7...8...9...100...1...2...3...4...5...6...7...8...9...10Optimized: 0 visible clusters (0.00%)
Total clusters visible: 96
Average clusters visible: 9
Building PAS...
Average clusters audible: 10
visdatasize:124 compressed from 160

writing z:\demonic dox\maps\testmaps\visleaf.bsp
0 seconds elapsed

Well, that definitely created a lot less clutter.

Where to place a HINT brush

We've seen how an object like a cylinder can create a lot of leafs. Anytime you have a large number of small brushes, for detail say; or an odd shaped brush (cylinders, arches, torus, spikes); or an area with water, a HINT brush can help a lot. Don't forget the leafs above and below you as well.
 
Last edited:
Oct 25, 2007
219
690
PART 3- AreaPortals

Now that we've talked about VISLEAFS and how they help render and ignore objects within your local vicinity, we'll talk about Areaportals that help render and ignore objects globally.

Although not all brushes are rendered, TF2 will keep track of every object in relation to you in the map. That is, unless you set distinctively sealed areas. Areaportals will divide a map into smaller sections, so TF2 only has to worry about the objects in your immediate location. This can speed up a map tremendously, especially on a large multi-stage map, like Dustbowl or Hydro.

However, once areaportals are put in place, they start trying to seal the different area. If the different areas aren't sealed, you get *** leaked *** errors again, inside your map.

To create a simple areaportal, create a thin brush that touches other brushes on four sides. Tie your areaportal brush to func_areaportal. There's your first areaportal brush. It's important the areaportal brush touches other solid (non-entity) brushes to seal an area.

There are three type of areaportals.

Open Areaportals
You put these in doorways and wall. Set the initial state to open.
This means that when you are in a VISLEAF that sees into the VISLEAF of the areaportal brush, it opens the second area by sight.

Closed Areaportals
You place a closed areaportal within a moving door or elevator. Set the initial state to closed, and identify the associated door under the name of linked door field. This areaportal brush will only open the second area to rendering when the door is open.

Areaportal windows
These are a little different. To avoid getting the "outer space" distortion from a leak when viewing two separated areas through a transparent brush, you need to create an areaportal window. The window will only become transparent when you get close enough to it.

First you'll need to convert your window brush to a func_brush entity and make sure to give it a unique name. This way the areaportal brush can be associated with it.

Create a new areaportal brush inside the window brush. Tie the new brush to func_areaportalwindow. Inset the window brush's name under the rendered window field.

The areaportalwindow entity helps seals the area and will only render the second area by sight, like an open areaportal entity does.

note: The tricky thing about an areaportal window is that it will not block vision, it just ignores everything in the area and renders anything that might be behind that area. Might not be too useful.

You can download a little areaportal map to see how the three types of areaportals work, and the problems I describes abour seeing through areaportalwindows. Download it here!
 
Last edited:

DJive

Cake or Death?
aa
Dec 20, 2007
1,465
741
Rep for you, this is awesome and exactly what i needed to explain piece by piece. thank you.
 
H

Haas

you can have a leaked entity without a hole if your complete model is inside a wall that touches the outside of your map.
Like i had.
And then you don't see the effects.
 

YM

LVL100 YM
aa
Dec 5, 2007
7,158
6,079
I'm gunna reitterate what I said since you've added later parts. :D good work! (rep++)
 

Hawk

L7: Fancy Member
Dec 3, 2007
419
213
Awesome! I needed to know more about hints. Thanks, Spaceweasels!
 

Tokit

L1: Registered
Jan 5, 2008
26
0
Where to place a HINT brush

We've seen how an object like a cylinder can create a lot of leafs. Anytime you have a large number of small brushes, for detail say; or an odd shaped brush (cylinders, arches, torus, spikes); or an area with water, a HINT brush can help a lot. Don't forget the leafs above and below you as well.

The only thing wrong with this part is that you don't even say where to place a hint brush. :sad:
 
Oct 25, 2007
219
690
The only thing wrong with this part is that you don't even say where to place a hint brush. :sad:

Unfortunately, at that point it become very map-centric. There are so many variables, such as map flow, visibility, distances, other shapes nearby. Even with all those elements in hand, the best thing to do is run the map, and see where the leaves are, and how best to simplify them.
 

Dox

L8: Fancy Shmancy Member
Oct 26, 2007
588
62
Thanks for the great tutorial... but I also could not help noticing...

"Loading Z:\dox\maps\testmaps\visleaf.vmf"

OMG Name buddies! Are you the reason "Dox" on Xbox live was taken? :)
 
Last edited:

Dox

L8: Fancy Shmancy Member
Oct 26, 2007
588
62
Quick question, do you texture areaportal brushes like hint brushes, only with the areaportal texture?
 

Termaximus

L5: Dapper Member
Jan 11, 2008
229
32
Nice Tuturial. Info on one of those 1% hard leaks to find.

Yes very nice tuturial. A lot clearer than some tutorials on this.

One weird thing I have found that causes a leak is when a point at circle (the little 'o' in the center of a brush/entity when selected) is outside in the void when the brush/entity is in the playable field. I'm not sure why this happens but it seems to occurs sometimes when moving a brush from the playable field, into the void, then back into the playable field in Hammer. I about pulled my hair out trying to find why a brush/entity cleary not in the void (and not an outside wall) was causing leaks. I figured it out by doing select all and it showed three litte 'o' out in the void and when I clicked them they were attached to entities.
Two fixes for this 1) delete the leaking brush/entity or 2)select the 'o' in the void and move it back to the center of your brush/entity. Hope this helps anyone having this issue.

FYI: My first custom map is out in beta 2.0 cp_2Skyscraper
 
Oct 25, 2007
219
690
One weird thing I have found that causes a leak is when a point at circle (the little 'o' in the center of a brush/entity when selected) is outside in the void when the brush/entity is in the playable field.

Yeah, the little 'o' is the origin. You can think of it as an anchor for the entity tied brush. It's important to keep that in the play area. Even if your func_door or move_linear entities leave the map, it won't leak as long as the origin is still in the play area (The origin doesn't move from a moving brush).
 

phatal

L6: Sharp Member
Jan 8, 2008
259
21
I added areaportals to my level and after doing a before and after fps with net_graph I have a decrease in fps by 5. Typically going from 98ish to 93ish.

I built my level hdr -slow used the demo and took screenshots lining up corners or lower fps areas using the demo circle. I then took a screenshot. Next I added areaportals where I thought they should go. Built my level once again hdr -slow and used the demo once more and referenced ss's off my secondary computer. None of the screenshots I took had a higher fps. :(

Does having a hint brush right next to areaportal have an adverse affect? Some were right next to each other.