[TIP] Leaks, Hints and Areaportals

Discussion in 'Tutorials & Resources' started by spaceweasels, Feb 6, 2008.

  1. spaceweasels

    aa spaceweasels

    Messages:
    219
    Positive Ratings:
    334
    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.

    [​IMG]
    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:


    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.

    [​IMG]
    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.
     
    • Thanks Thanks x 18
    Last edited: Feb 6, 2008
  2. spaceweasels

    aa spaceweasels

    Messages:
    219
    Positive Ratings:
    334
    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:
    [​IMG]

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

    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:
    [​IMG]

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

    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.
     
    • Thanks Thanks x 17
    Last edited: Feb 6, 2008
  3. spaceweasels

    aa spaceweasels

    Messages:
    219
    Positive Ratings:
    334
    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!
     
    • Thanks Thanks x 22
    • Like Like x 1
    Last edited: Feb 6, 2008
  4. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,739
    You definalty deserve user of the year :D
     
  5. DJive

    aa DJive Cake or Death?

    Messages:
    1,466
    Positive Ratings:
    736
    Rep for you, this is awesome and exactly what i needed to explain piece by piece. thank you.
     
  6. Haas

    Haas Guest

    Positive Ratings:
    0
    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.
     
    • Thanks Thanks x 1
  7. hsnopi

    hsnopi L1: Registered

    Messages:
    1
    Positive Ratings:
    1
    oh man.
    EXCELLENT!!
    thanks:)
     
    • Thanks Thanks x 1
  8. Snipergen

    Snipergen L13: Stunning Member

    Messages:
    1,053
    Positive Ratings:
    150
    Oh god this is just perfect again :D DONT EVER STOP SPACEWEASELS! :D
     
    • Thanks Thanks x 1
  9. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,739
    I'm gunna reitterate what I said since you've added later parts. :D good work! (rep++)
     
  10. Hawk

    Hawk L7: Fancy Member

    Messages:
    419
    Positive Ratings:
    212
    Awesome! I needed to know more about hints. Thanks, Spaceweasels!
     
  11. phatal

    phatal L6: Sharp Member

    Messages:
    259
    Positive Ratings:
    21
    You need your own website for tutorials. I used this today to find a leak I had.

    +rep
     
  12. Tokit

    Tokit L1: Registered

    Messages:
    26
    Positive Ratings:
    0
    The only thing wrong with this part is that you don't even say where to place a hint brush. :sad:
     
  13. spaceweasels

    aa spaceweasels

    Messages:
    219
    Positive Ratings:
    334
    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.
     
  14. Dox

    Dox L8: Fancy Shmancy Member

    Messages:
    588
    Positive Ratings:
    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: Feb 11, 2008
  15. Dox

    Dox L8: Fancy Shmancy Member

    Messages:
    588
    Positive Ratings:
    62
    Quick question, do you texture areaportal brushes like hint brushes, only with the areaportal texture?
     
  16. spaceweasels

    aa spaceweasels

    Messages:
    219
    Positive Ratings:
    334
    Good question.

    All faces on an area portal should have the same texture (areaportal).

    Heh, no. "Dox" is my shorthand for 'documents' (docs).
     
  17. Termaximus

    Termaximus L5: Dapper Member

    Messages:
    229
    Positive Ratings:
    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
     
  18. l3eeron

    l3eeron L8: Fancy Shmancy Member

    Messages:
    594
    Positive Ratings:
    85
    +w00t!

    er I mean +rep
     
  19. spaceweasels

    aa spaceweasels

    Messages:
    219
    Positive Ratings:
    334
    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).
     
  20. phatal

    phatal L6: Sharp Member

    Messages:
    259
    Positive Ratings:
    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.