Tools Texture Use: Part 4
Tutorial Quick Nav
1.0 - Brief Intro
2.0 - Areaportals Effect
3.0 - Proper Uses
3.1 - Intro
3.2 - Valve Map Examples
4.0 - Getting Started
5.0 - General Areaportals
5.1 - Brief Situation Intro
5.2 - Sealing Your Entrances
5.3 - Leaks - They happen
6.0 - Areaportal Windows
6.1 - Brief Situation Intro
6.2 - Sealing Your Windows
7.0 - Final Words/Warnings
Brief IntroAreaportals are among the best and greatest of optimization techniques in source mapping, quite simply the strongest and most effective form of breaking your level into many different sub-levels that can be rendered individually with absolute control by yourself where and when this slicing will occur, hint brush's can do this same effect yes, but they are just that, hints for the engine to consider but it may not know the intention in which you placed it there. That is where areaportals come into use, no matter what they will be used as you set them, the engine cannot ignore anything done or set with your areaportals. That fact alone makes them useful in several different situations. For those familiar with hint brush's and vis leafs and what they all are in both the compilation process and final bsp product of a map, much of this will be the same with a few new twists and options thrown in, Be warned, this is a very touchy tool to work with, if not handled correctly you will do more harm than good, at best a failed compile / leak, at worst...well, we won't go there just yet. Much like hint brush's and vis leaf effects areaportals are also a client sided effect, where each user will have a different view on whats rendered and whats hidden, so if one person enters an area and the rest of the areas are off to him, doesn't mean another player in another area will have their current spot turn off too. While the visual effect itself is client sided, the server still controls them. The I/O triggered open/close states of areaportals enabled on all clients, so a closed/open areaportal in this case will be the same to all users. So their use must be chosen carefully otherwise you could wind up in a situation where you have an areaportal brush close and remove a section of the map that shouldn't be removed in another persons perspective if you've placed it very poorly in the open. Thats why they must be used correctly to avoid these errors. Its much easier to design levels with all your optimization in mind first rather than as an afterthought as you will find that brushwork you thought turned out so well then becomes your worst nightmare, now don’t get me wrong its still very possible to optimize levels after the fact, its just more time-consuming and tedious to do in most cases. Nothing wrong with making a section messy and fixing it up afterwords, just make sure you do go back and fix it. While I do suggest that any mapper interested in getting the best performance out of their creations read this tutorial, I still however, encourage you to look over some other basic optimization tutorials on hint brush's / vis leaf editing or some of my previous tools textures to start getting a feel for how delicate some of these systems can be. Especially if this is going to be your first jump into proper optimization, don't want to bite off more than one can chew here as you will just end up destroying your level. So please browse through the tutorial section here and read and understand the simple vvis process and hint/skip work before trying these out.
Areaportals EffectThe effect that can be gained by areaportals themselves are among the best if not top tool in which to optimize any level. What the areaportal texture itself can do can be compared to that of the cordon tool some of you may have experience with in the past. That hammer tool comes in handy for level designers in the beginning stages of their maps when they want to see sections of a map built quickly without having to process the rest of the map. It “Cordons” off the area you want, the same with areaportals, they enclose each area you would like to be its own separate section of the map to be rendered on its own with no external parts of it visible/processed, excluding a 3d skybox of course. And just like the cordon tool the areaportal brush will become the texture of the skybox you have selected in correct scaling and placement. Keep that little note in mind at all times as you don’t want something to be hidden by your sky when it makes no sense to be if using triggered areaportals in an open section of the map. In the screenshot provided you can see that there is nothing but a simple hallway with alternating colours on the floor, Now where the caution strip is in the screenshot, thats the area where we have placed our triggered areaportal to seal off that part of the level. So we step into the area that triggers the areaportal to turn on and viola: The level has been cut in half completely, no models, brushes, decals, overlays etc. That no longer exists in the level and doesn't have to be processed anymore. Now a player on each side only sees their respective half, objects, bullets, props etc can pass through areaportals and be effected by objects on the other side as if it was not there because areaportals are just a visual effect to help computer performance and not a solid wall, the server still knows where everything is and you can walk through an areaportal just fine, it will simply hide the other half of the room for you. Just note, bots and NPC's do not take closed or open areaportals into consideration on whether they can see you or not, server says that your in their line of sight they will shoot regardless of your view towards them being disabled by a closed areaportal or completely opaque areaportal\_window. HL2 campaign has a few moments like that for those who notice them anyways :P Open areaportals have a benefit as well, most think of an open areaportal as a disabled one from experience with other tools, such as the occluder. Where when they are on they block what they are meant to and when off they don't do a single thing. Well, for areaportals this is not true. Both in the open and closed states they perform a function. Multiplayer games have the best use of open areaportals with closed/toggled ones used only on doors. The reason behind open areaportals being the main use is due to the aforementioned error that you could wind up with with toggled ones used in situations they shouldn't be. When in the open state they don't block off everything from that and beyond it as with the closed state, but rather block what you don't see through the areaportal itself. Think of it as a filter, removing all the visleafs that are to all the other sides of it leaving on the leafs that you can see through the areaportal being the ones rendered. Now while you could potentially achieve the same effect with some hint/skip work, but why take all that extra work to make every possible angle on all entrances/exits when you would probably just make a huge mess of the visleafs anyways. Heres a comparison of the normal rendering done with just basic visleafs and then below it one with an areaportal to filter your view. *Any connected visleafs are rendered in the other room.
*Only visleafs within the perspective through the open areaportal are rendered. So now you can understand just how much this single tool can improve your level designs in terms of performance and speed. You can manually specify what you want the player to be able to see, unlike normal hint brush’s which can have several if not all leafs visible if it sees fit, even if you do not think it will act that way, 90% of the time normal vvis fails at understanding just how your level should be broken up and what should be visible at what time. It happens, no system is perfect, so we have our tools to use to improve this. Lets get to it shall we?
IntroLike any tool in real-life and in hammer, they must be used only when it is appropriate in which to do so, Can't use a sledgehammer everywhere even though it would be fun now can we? So we're just going to go over what you should and shouldn't be doing with areaportal entities in your levels. Now I may be using some terms that you don't understand but I will try my best to explain some concepts, using dictionary definitions if I have to. You should try to build maps with each combat area in mind beforehand with access between them via paths, ie for a DE style map, there are generally around 7 different areas that make up the map, 2 spawns, 2 bombsites, 2 staging areas for those sites and Mid of course. These are your main zones for players to fight against one another, so we should limit what they see and interact with to just this single zone so that they get the best performance out of their own computers. So areaportals come in to divide the map into their each respective sections resulting in these main areas. But they should ONLY be used to define these zones in such a way that you have not overly complicated the system in which it functions, overuse of areaportals in a small space can create worse performance for the clients computer than if you didn't have them at all. Its all about smart placement, not spammed.
Valve Map ExamplesCS_Militia
Getting StartedFor the duration of explaining and showing how to go about creating/fixing/checking areaportals I will be using a relatively completed Map In Progress available for download from here, DE_Inner-City by . It has several good aspects to it that make it perfect, one, to show off how to seal areas and what needs to be done, and two, a good testing ground for you to do the same thing if you wish while or even after reading this tutorial. Don't be afraid to rate it while your there either, or complete the map itself for that matter. Section exists for that purpose. Anyways, back on track. Here is an simple overview of the entire map. I've made different sections highlighted with various colours to show off how I would be breaking this level up into its different areas. You could do it even further to have all intersections separated but that could add up just too many areaportals to provide benefit. These are some of the ones I'm going to be making during this tutorial, you may have chosen different groups/divisions and thats perfectly fine, I may even have missed some I could have done but for the moment just the basics will be fine for this tutorial and also has to do with that the map is not complete so sections are missing as a result :P
Brief Situation IntroFor those that haven't downloaded and taken a look at the map already, the completed sections of the map in terms of structure are the snipers nest on the upper left corner of the overview, the street and underpass below that, the offices and elevator building, the warehouse section and side entrances, and lastly the sewer system and the few roads connecting everything. As the map is for the moment, as most new mappers do constantly and the experienced ones use only in initial creation and testing of maps, the entire level is inside one giant box. This is hell on vvis to process and then as a result, for us to create and use areaportals in. But it takes no time at all to redo the skybox and have it hug all the walls around the routes for the map so it can then be broken into its smaller chunks by ourselves. Now thats a rather quick and dirty fix I've done as personally have no intention of finishing/polishing the map, just using it for the examples. But you can see the benefit from making the skybox conform to that of the level itself rather than resorting to the giant box method. So now that the level is in proper form to begin work, lets start with the most complete area of the level, The snipers nest.
Sealing Your Entrances
Leaks - They HappenBecause the areaportal acts like a cordoning tool in-game, each area that you seal off with this entity can leak independently of each other, that’s not so good, but the reason why is pretty clear. Since each of these areas are now considered their own levels when active, if there is a way that it can get outside of itself in any way, then just like a normal map, it will leak and a compile will fail or cause other errors. Now when loading the pointfile, you may be confused to see a red line going from inside your map to inside your map, that’s due to the areaportals again, you need to take a good look at the situation in which you used these entities and make sure that every entrance was sealed completely with the areaportal entity. When in doubt, just compile BSP only, then load the pointfile, seal the gap in the area as shown, repeat as many times as necessary. There cannot be any gaps, just like a normal map that will allow something to get outside of these areas. Precision is something you will get used to. Now you might as well optimize the use of these areaportals as well, in some cases you can use a single brush based entity and stretch it to cover two separate entrances, ie if you had two corridors separated by a wall between that led to a central room, might as well just have one brush go across both entrance ways so you don’t waste another 4 brush’s when you don’t need too. Areaportals are allowed to be inside normal map geometry, just don’t go overboard as trying to fix any leaks afterwards with that work gets messy to the point of a brick going through your monitor. Try to keep the brushwork clean and easy to work with so optimization becomes easier to do. If you have any func\_detail entities in your map in any large quantity, those also may be the cause of a leak, you cannot rely on them to seal something from the void that is the rest of your map, the whole point you tied them to func\_detail was so that they would not be normal geometry and would be ignored by the vvis process completely and speed up the compilation process. Double check your geometry in the area of the leak for any of these entities. Use the auto visgroups tab to toggle on and off this group for quicker analysis of the area. Most of the time this is the issue and its quickly fixed by moving it back to world and selecting the more fine brush detail on the group and only tying those to func\_detail. Entire walls generally shouldn't be detail brushes, but only the tiny smaller ones on its surface that are not needed to block visibility in any way.
Brief Situation IntroFor the windows section of this tutorial I'm going to be using the Office space area of de\_inner-city as it has several spots we are going to turn into portal windows as well as some outside of it as well.
Sealing Your WindowsSlapping areaportal\_windows just on any window won't work. You still need to seal the rest of the area just as you did with the general areaportals section of this tutorial. These are just an extension of them with more settings. Always use the cordon tool to do simple bsp only compiles of your newly created areas to test them for leaks, during this tutorial I encountered dozens just from missing geometry to func\_detailed objects. Also, keep in mind that window frames, just like doors, tend to be sticking out or being sunk into the existing wall geometry and are most likely func\_detail as well. Therefore the areaportal window needs to encompass those gaps to correctly seal the area. Easiest way to construct areaportals either in the general format or window format is to use the autovis groups and hide everything not needed, brush entities, point entities, detail entities etc and just leave only the bare structure of your map intact.
Final Words/WarningsWhile areaportals are very powerful and seem like can be used everywhere and will improve your map drastically, they also exact a certain cost to resources when there are more than one on the screen at a time, so while they are great to have in maps, limit them to where you need them rather than having them everywhere as the performance increase may be minimal at that point. If your not sure if your getting a performance boost out of an area then disable it and compile it without them, if it runs better/worse act accordingly. A simple warning about water. If you have an areaportal thats cutting off a section of a water brush and crosses the surface from above to below, you need to split the areaportal brush into two separate areaportal entities that meet right at the surface of the water. Now just to reiterate some general rules/properties for areaportals:
They must only be made from 1 brush Areaportals must be tied to func\_areaportal or func\_areaportal\_window Areaportals must be completly textured with the tools/toolsareaportal texture ONLY. They cannot have displacements contained within their volume Areaportals must be tied to func\_areaportal or func\_areaportalwindow as the brush with just the texture does nothing. Server events/controlled entities are not effected by portals. ie, Bots shoot through closed portals Areaportals along the same plane will merge together ingame Areas can leak independently Areaportals are non-solid Areaportals cannot cross the surface of a water brush Open Areaportals filter out rendered visleafs based on perspective seen through the open portal Closed Areaportals remove all visleafs beyond the portal from being rendered