Go Back   TF2Maps.net > Discussion > Mapping & Tutorials > Tutorials

Notices

Reply
 
Thread Tools

[Tutorial] Areaportals - All you need to know
Old 11-02-2009, 02:46 PM   #1
Psy
What sick man sends babies to fight me?
 
Psy's Avatar
 
Psy is offline
Posts: 1,461
Thanks: 489
Thanked: 874
Default [Tutorial] Areaportals - All you need to know

Here's a guide all about areaportals. Where to use them, where they are used, and just what the hell they do!


What is an areaportal?

An areaportal is a means of reducing the amount of objects that the engine has to render based on the player's viewing angle (the view frustrum) through an areaportal or a bunch of areaportals that are visible.

Here's a simple diagram.



Imagine this as a room with a wall dividing the area into 2 parts and in the center of the wall is a window. In this window, an areaportal is placed. On the one side of the wall is the player and on the other are 4 oildrums in a neat row represented by little black circles.. In red is the area outside the view frustrum and in green is the area inside the view frustrum.

As you can see, the two oildrums are inside the view frustrum (remember, this is the player's view) and so they are being rendered whilst the oildrums outside the view frustrum are not. This means that everything which the player cannot see is not being rendered. Useful!

Now let's put this to practice.


A simple example



Download this map! - Includes BSP and VMF

Here is the same example previously described but made for real. It's the exact same setup as shown in the diagram except their are considerably more oildrums.

Let's view this setup in game with some fancy comparisons to nail the point home!



With the areaportal off, that's every single oildrum in that section of the room being rendered. All 32 of them.



With it on, you will notice that oildrums on the left and the right are no longer being rendered. Clearly our areaportal friend is doing his job as he prevents the oildrums outside the view frustrum from being rendered!

Now let's move closer and into a corner to see what's being rendered - remembering how our viewing angle affects the number of objects being rendered.



And now let's turn it on again.



As you can tell, that's a huge difference that when applied to real maps can greatly benefit it's performance. Speaking of which...


Show me more (real life) examples!

Now for a series of real-life examples taken from multiple stock and custom maps. Green bits represent where an areaportal has been placed. A description is written below each group of images.




Looking to the right and left, you can see the number of objects that are no longer being rendered which includes both props and brushes.






It's the same ordeal here but the difference is more extreme because the angle of the view frustrum is more acute then before. Most objects behind the wall on the left are no longer rendered.






Again, it's the same. Lots of stuff being unrendered.



Basic Areaportal Construction

Areaportals are very easy to create within your map. Essentially, you place areaportals at every exit (doors, windows, etc) within an area to seal it off just like you would seal a map off from the void using world brushes. Creating one is as simple as creating a brush which completely fits the size of whatever you are trying to seal off, texturing it using toolsareaportal and then tieing it by hitting CTRL + T and choosing func_areaportal from the drop-down menu.

Here's a simple example of how you would use areaportals in a simple room with 2 areas.



Area 1 has two areaportals at either exit leading into Area 2. This will work correctly. However if we were to remove one of them...



...VBSP will get very angry and tell us that an areaportal "doesn't touch two areas". Loading up the pointfile will give us a red line which loops back out of the first leak it finds withing the area and back round into our single areaportal.



Where and When to Use Them

There are many ways in which areaportals are used. Here are some various methods.

The 'Door' Method

This method involves 'opening' and 'closing' an areaportal linked to a func_door. When the door opens, the areaportal opens; when it closes, the areaportal closes. You link your areaportal to your door by entering the name of the door under the 'Name of Linked Door' property of your chosen areaportal.

Remember, when the areaportal is closed, anything behind it will not be rendered so make sure the areaportal is thin enough to fit inside the door brush or model otherwise it will disappear when the areaportal closes.

The 'Always Open' Method

These areaportals are used extensively and are the same type used in the simple example shown earlier in this tutorial. Here are a few examples from Valve maps to show how they've used them.



This is by far the most common usage of areaportals; used to section internal rooms within a building nice and neatly.


This is where we start to get a little more creative. This areaportal splits the middle area of Badlands from the 2nd CP area by fitting between the forward spawn building and the skybox near-by.



Merging !- SUPER IMPORTANT -!

Merging is something important to note! If several areaportals are along the same plane AND share common edges then VBSP will merge them all into one areaportal regardless of distance.



Here are two areaportals. They are both the same height and thickness and are both the same distance from the floor. If we look in game, and enable r_drawportals 1 we will see 1 gigantic green box extending between both areaportals.



This means they have been merged into 1 single gigantic areaportal. Now merging isn't a problem unless you have 2 areaportals incredibly far apart that merge together thus rendering their purpose completely useless like in my experience. However stopping areaportals from merging is simple! Simply change the height, width, or thickness of the areaportal so it's different from the other areaportals along the same plane and it will prevent them from merging.



So I would simply change areaportal 2 from a thickness of 16...



...to 8 and...



...voila. 2 seperate areaportals!


Conclusion

Hopefully you should have an understand of how areaportals work and where and when to use them. Hopefully.
__________________
Lighthouse | Nightfall | Converge | Overwatch | My Portfolio

Last edited by Psy; 11-02-2009 at 02:50 PM..
  Reply With Quote

Old 11-02-2009, 02:51 PM   #2
Joodude
Mappers gonna Map
 
Joodude's Avatar
 
Joodude is offline
Posts: 684
Thanks: 722
Thanked: 328

I love you. Permanently. Forever.
__________________
Quote:
Jake | TF2maps.net: HOLY CRAP MEATBALL SUB IS THE NEW UNLOCK
Jake | TF2maps.net: BURN SPY'S EYES WITH MELTING CHEESE
  Reply With Quote

Old 11-02-2009, 02:55 PM   #3
Ravidge
Grand Vizier
 
Ravidge's Avatar
 
Ravidge is online now
Posts: 989
Thanks: 321
Thanked: 880
Blog Entries: 6

Good tutorial!

I also had some troubles with merging areaportals, http://dl.getdropbox.com/u/1281220/plr_panic_b10007.jpg

Really important thing to double check before release!
__________________
Finished: Silvertrail | System
WIP: Panic | Enigma | Fusion
  Reply With Quote
The Following 2 Users Say Thank You to Ravidge For This Useful Post:

Old 11-02-2009, 02:56 PM   #4
gamemaster1996
Lv? : Spy
 
gamemaster1996's Avatar
 
gamemaster1996 is offline
Posts: 629
Thanks: 874
Thanked: 64
Blog Entries: 1

Thanks i finally know how to do areportals without the compile getting in a strop.
Saving this page for offline view now
__________________
An eye for an eye makes the whole world blind, i would've thought a knife in the eye would make anyone blind better.
  Reply With Quote

Old 11-02-2009, 03:06 PM   #5
Nutomic
Mapping Coding Drinking
 
Nutomic's Avatar
 
Nutomic is offline
Posts: 868
Thanks: 201
Thanked: 169

Could you also give the commands you used there? Only one i recognize is mat_wireframe.
__________________
  Reply With Quote

Old 11-02-2009, 03:08 PM   #6
Psy
What sick man sends babies to fight me?
 
Psy's Avatar
 
Psy is offline
Posts: 1,461
Thanks: 489
Thanked: 874

All I used were r_DrawPortals and mat_wireframe.
__________________
Lighthouse | Nightfall | Converge | Overwatch | My Portfolio
  Reply With Quote
The Following 2 Users Say Thank You to Psy For This Useful Post:

Old 11-02-2009, 03:29 PM   #7
Terr
Veteran Member
 
Terr's Avatar
 
Terr is offline
Posts: 1,291
Thanks: 36
Thanked: 340
Default

IMO the real unsolved problem is determining when an areaportal is "worth it" from a performance standpoint.
  Reply With Quote

Old 11-02-2009, 03:32 PM   #8
martijntje
Veteran Member
 
martijntje's Avatar
 
martijntje is offline
Posts: 520
Thanks: 91
Thanked: 155

I'm realizing I dont have any areaportals in my map. I do have to do that.

Nice tutorial, I didn't know that about the merging of areaportals
__________________
  Reply With Quote

Old 11-02-2009, 03:48 PM   #9
Owlruler
Mark of Owl Approval
 
Owlruler's Avatar
 
Owlruler is offline
Posts: 896
Thanks: 39
Thanked: 246

Thanks!
__________________
I am a bad person, please attack me with various Owl-related insults.
  Reply With Quote

Old 11-02-2009, 04:17 PM   #10
littleedge
Expert Clipper
 
littleedge is online now
Posts: 461
Thanks: 107
Thanked: 263

So any mirrored map, like Panic, is going to experience that merging area portal thing? Good to know. Expect me to forget, though.
  Reply With Quote
Reply

Tags
areaportals

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -5. The time now is 04:54 PM.

© 2008 Valve, the Valve logo, Team Fortress 2, the Team Fortress 2 Logo, Steam, the Steam logo, Source,
the Source logo, and Valve Source are trademarks and /or registered trademarks of Valve Corporation
in the United States and other countries.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Ad Management by RedTyger