Documentation/Articles/Overview of Portal System

From NeoAxis 3D Engine Wiki

Jump to: navigation, search
Go to higher level


The Portal System is designed to optimize indoor rendering performance. Spending time to configure the portal system will reduce the rendered triangle count and drawcalls, thus increasing FPS.

Portal system consists of three object types:

  • Zone, represents the various places: for example a room.
  • Portal, represents all possible opening in the area: for example windows and doorways.
  • Occluder, indicates various portal switches: for example doors.

The portal system constists of zones (rooms, corridors...) linked together with portals (doorways). Each portal connects 2 zones or one zone and the outdoor. Finally for objects that can block the portal (doors) we use occluders.

PortalSystem 01.jpg

Tutorial - Setting Up The Portal System

In this tutorial we will configure the portal system for a small map.

For this tutorial, we will need a map with the following objects: HeightmapTerrain, Light.type, SkyBox, and 2 rooms - large and small.

PortalSystem 02.jpg

To begin with, we create a new map layer specifically for the portal system. It is not a mandatory step, but it makes editing of complex maps much easier. Right click on Root Layer in Objects window. Create a new layer called: "Portal System".

PortalSystem 03.jpg

Objects will be created in the selected layer. You can also assign a layer to an already finished project, by changing the Layer block of the objects in the properties panel.

Having dealt with the layers, we can now start setting up the portal system. First we need to add Zone.type to the map. For this select thelayer created before, to make sure that the zone will be added to this layer. Now choose the Zone.type object in the Object Creation panel. It's located in the Base\Types folde. Place the zone in the center of the large room. After having created the zone press spacebar to stop object creation.

PortalSystem 04.jpg

Now we need to scale the zone up to the room size by using transformation tools. This is what it will need to look like:

PortalSystem 05.jpg

Do the same for the small adjacent room.

PortalSystem 06.jpg

Remember, that the adjacent zones must be slightly overlapping themselves.(The reason will be explained a bit later).

On our map, all indoor spaces are covered with zones and all that is left to do is to place the Portal.type. Portals are placed into building openings. On our map we have four openings, so we will need four portals: the first is the the one between the large and the small room, and the three others - the exit doors.

Placing portals is not a big deal, but we must pay attention to the doors. The door contains an Occluder.type entity, i.e. it has the ability to turn off the portal. The portal is turned off only when it's located completely inside the occluder. In Door.type, the occluder is a bit bigger than the door. So we need to make the portal as big as the door in order for it to fit fit perfectly into the occluder.

Let's get back to the creation of the portal system. We need to add the portal on the map. In Object Creation panel, select the Portal type in the Base\Types folder.

We started the tutorial by making a layer for the portal system. You will find out that using layers is extremly useful. You can disable the geometry display (by clicking on the eye icon next to the Corridors folder), so you can place the portal without being bothered by the meshes.

PortalSystem 07.jpg

It was mentioned above that adjacent zones should be slightly overlapping. This necessity is related to how portals are working. The portal between two zones must be located at same time in both zones. If this condition is not met for one portal, you will get 1 invalid portal message on the editor screen.

Now make put one more portal that will represent of one of the three doors of the large room. Contrary to the first portal, this will connect the room with the outdoor. Therefore, set the Outdoor parameter to True in the portal property.

PortalSystem 08.jpg

The arrows of the portal must indicate on which side the outdoor is. If they indicate the wrong side, the portal must be rotated by 180 degrees along the Z axis. Moreover, a part of the portal must be located inside the zone and the other outside of it.

Repeat the last actions and add two more portals to the map for the two other doors.

To test the portal system, we need a static object. Place the ogre head in the large room - type OgreHead in the "Types\StaticObjects" folder.

PortalSystem 09.jpg

Save the map and run the simulation.

PortalSystem 10.jpg

When in game, trigger the NeoAxis Engine menu by pressing Escape. Then open the Profiling Tool window and select the Settings tab, in which you will tick the Wireframe box, so we can see the geometry in wireframe.

PortalSystem 11.jpg

If you can't see the ogre head when you are in the small room, then the portal system is working correctly.

PortalSystem 12.jpg

Go to the door to open it. If you see the ogre head, this means that the doors's portal is turned on and working.

PortalSystem 13.jpg

We have learned how to set up the portal system. But what about the Occluder.type? We have already dealed with occluders when we placed portals for doors. To add an Occluder on the map, choose it in the Object Creation window, it's located in the Base\Types folder.

It is also possible to attach occluders to entity types, for texample the door, Door.type. This type is made of three attached objects: two door meshes and an occluder. There are articles on working with Resource Editor, and making objects with occluders attached, which can be found in Object Type Editor.

PortalSystem 14.jpg

Congrats, you now know everything about the portal system!