Difference between revisions of "Portal Basics"

From Mod Wiki
(Batch update)
 
m (playzoneportal)
 
(3 intermediate revisions by 2 users not shown)
Line 9: Line 9:
 
== Creating a portal ==
 
== Creating a portal ==
 
A portal is created by assigning all but one face of a brush the [[Common Textures#common/nodraw|nodraw]] texture. The remaining face should be given the portal texture ([[Common Textures#common/visportal|visportal]], [[Common Textures#common/outsideportal|outsideportal]], or [[Common Textures|otherwise]].) The face with the chosen portal should cut completely through the area to be portalled - that is, the portal-textured face should touch ceiling, floor, and walls on both sides. Usually, this means portals are rectangular.
 
A portal is created by assigning all but one face of a brush the [[Common Textures#common/nodraw|nodraw]] texture. The remaining face should be given the portal texture ([[Common Textures#common/visportal|visportal]], [[Common Textures#common/outsideportal|outsideportal]], or [[Common Textures|otherwise]].) The face with the chosen portal should cut completely through the area to be portalled - that is, the portal-textured face should touch ceiling, floor, and walls on both sides. Usually, this means portals are rectangular.
 +
 +
'''Patches may not be used for portals. Portals must be completely flat.'''
  
 
[[Image:Portals_goodbad.jpg|frame|none|How to set up a simple portal correctly.]]
 
[[Image:Portals_goodbad.jpg|frame|none|How to set up a simple portal correctly.]]
Line 56: Line 58:
 
* Texture: <tt>/textures/editor/playzoneportal</tt>
 
* Texture: <tt>/textures/editor/playzoneportal</tt>
  
Used to separate a map into two or more playzones - in the same manner that Slipgate is split across two environments. Each of Slipgate's environments are surrounded with a playzone portal hull.
+
Used to separate different parts of a map and their playzone markers. For example, these can be used to assign different playzones to separate parts of a building.
 +
<!-- what a rubbish description - dj -->
  
 
== Developer Commands ==
 
== Developer Commands ==
 
[[Image:Portals_showportals.jpg|frame|left|r_showPortals in action]]
 
[[Image:Portals_showportals.jpg|frame|left|r_showPortals in action]]
 
* {{consolecmd|r_showPortals 0/1/2/3}} - turns on rendering of portal outlines so it's possible to see which portals are active (rendered green) and which are not (rendered red). This is a good command to use to help understand how portals work and where they are placed in other maps. Setting {{consolecmd|r_showPortals 3}} displays what type each portal is.
 
* {{consolecmd|r_showPortals 0/1/2/3}} - turns on rendering of portal outlines so it's possible to see which portals are active (rendered green) and which are not (rendered red). This is a good command to use to help understand how portals work and where they are placed in other maps. Setting {{consolecmd|r_showPortals 3}} displays what type each portal is.
* {{consolecmd|t_usePortals 0/1}} - turns on/off portals (when turned off, everything is drawn, whether it is visible or not)
+
* {{consolecmd|r_usePortals 0/1}} - turns on/off portals (when turned off, everything is drawn, whether it is visible or not)
 
{{clear}}
 
{{clear}}
  

Latest revision as of 15:16, 2 January 2008

Portals are not teleporters!

Portals are used to reduce the amount of work the renderer has to do. In essence, a portal is a window into an area of a map; if the renderer can not see a portal into an area of the map, it knows the area behind the portal can not be seen by the player either, and therefore does not need to render it. Similarly, if the player is very far from the portal, such that it only uses a few pixels on the screen, the renderer knows it's not worth rendering the area behind it.

The important thing to understand is that portals are only useful when used to distinguish separate areas, and when the area they hide is complex enough to make it worth not rendering. Hence portals are usually created in doorways or entryways that are crucial for the player to get from one part of the map to another.

There are several types of portals. 'Visportals' are the most basic and simply won't render the area behind it when it itself isn't on-screen (or is too small to be considered worth rendering). Other portals are used to control the flow of light and to alter the ambient lighting within the different interior sections of maps. However, all portals are created in the same way and follow the same basic rules.

Creating a portal

A portal is created by assigning all but one face of a brush the nodraw texture. The remaining face should be given the portal texture (visportal, outsideportal, or otherwise.) The face with the chosen portal should cut completely through the area to be portalled - that is, the portal-textured face should touch ceiling, floor, and walls on both sides. Usually, this means portals are rectangular.

Patches may not be used for portals. Portals must be completely flat.

How to set up a simple portal correctly.

It is also important to note that portals must completely seal areas from each other. So if you have two rooms joined by three doorways, if you add a portal to one doorway, you need to add a portal to the other two doorways as well. In other words, it should be impossible to look at one side of a portal and then look at the other side without needing to pass through a portal to do so.

Portal types

visportal

The most common portal, used to hide areas of a map that should not be rendered when the portal is not in view. Note how the green visportal texture is placed in doorways - when those doorways are not in view, the areas behind them will not be rendered. Also note how the purple 'nodraw' texture in the first screenshot is actually the backside of the bigger portal in the second screenshot.

visportal placement in Sewer
visportal placement in Sewer

Uses

Visportals serve two main purposes:

  1. They can reduce the number of polygons that need to be drawn, hence
  2. They can reduce the number of textures that need to be in memory

The combination of these means that portals can lead to significant performance gains, as the renderer has less work to do. Hence some areas can use more detail than normal, knowing the additional detail will be culled away by portals when not in sight. Conversely, portals can also make the game more accessible on lower-spec machines as the renderer knows which areas can be safely culled without affecting the experience for the user.

The difficulty is placing portals and geometry appropriately. If placed badly, it can mean that two high-detail areas are in view at the same time, so the engine renders many more polygons and uses more texture memory, in some cases leading to a sudden decrease in performance.

ambientportal

Used to separate ambient lighting areas defined by light_ambient entities.

audioportal

  • Texture: /textures/editor/audioportal

Used to separate areas of sound, for example to make sure the sound of machinery in one room doesn't leak into an adjacent room.

aasclusterportal

  • Texture: /textures/common/aasclusterportal

Distinguishes to areas for AAS generation purposes.

outsideportal

Used to separate the inside (indoors) and outside (outdoors) of a level, in order to control light (and shadow) from sunlight.

playzoneportal

  • Texture: /textures/editor/playzoneportal

Used to separate different parts of a map and their playzone markers. For example, these can be used to assign different playzones to separate parts of a building.

Developer Commands

r_showPortals in action
  • r_showPortals 0/1/2/3 - turns on rendering of portal outlines so it's possible to see which portals are active (rendered green) and which are not (rendered red). This is a good command to use to help understand how portals work and where they are placed in other maps. Setting r_showPortals 3 displays what type each portal is.
  • r_usePortals 0/1 - turns on/off portals (when turned off, everything is drawn, whether it is visible or not)

Additional Resources