Documentation/Articles/Overview of Portal System

From NeoAxis Engine Wiki

Jump to: navigation, search
Go to higher level
Portal System

Description

Portal System is designed to optimize indoor rendering. Indoor - it's usually rooms and corridors; outdoor - open great spaces. Spending the time to configure portal system will reduce the rendered triangle count, thus increasing FPS.

Portal system consists of three object types:

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

Thus we consider the portal system: It consists of zone that are related to portals (doorways). Each portal connects any two zones or one zone and outdoor. Finally for objects that can block the portal (doors) we use occluders.

Tutorial - Setting up the portal system

In this tutorial we will configure the portal system for a small map. Objects that we need are a room (Rooms.mesh, located in "Data\Models\Rooms") and a pair of doors (Door.type, located in "Data\Types\Dynamic\Door").

Placing Rooms.mesh

To begin with, we will create a new map layer specifically for the portal system. It is an optional step, but it makes editing complex maps much easier. Right click on Root Layer in Map Entities window. Create a new layer called Portal System.

Portal system8.jpg

Objects will be created in the selected layer. You can also assign a layer to already finished project, by changing the Layer property.

Portal system9.jpg

Having dealt with the layers, we can proceed directly to the creation of the portal system. First we need to add the zone to the map. Choose Zone type from Base folder in Entity Types window.

Portal system10.jpg

Place the zone to the center of a room. We need to do a little work and scale the zone up.

Portal system11.jpg

This is what we must have:

Room zone (top view)

In addition to the main room, Rooms.mesh also has a small corridor. We need to create a zone for it too.

Corridor zone (top view)

Remember neighboring zones must be really close to each other. Later we will explain why is this necessary.

On our map all indoor spaces are covered with zones and all that is left are portals. Portals represent openings in buildings. On our map we have two so we need two portals - first for the door connecting room and corridor, and second for the exit door.

Placing portals is no big deal, but we must position it correctly. Door is occluder i.e. it switches the portal. Portal is switched off only when it is completely inside the occluder. in Door.type occluder is a little larger that the door. So we need to make the portal as large as door so it will fit perfectly into the occluder.

Add the portal to a map. It is located in the Base folder.

Portal system14.jpg

We started the tutorial by making a layer for portal system. Easy to use, it will automatically reveal itself when you add a portal (or any other object) to it. Disable the geometry display (by clicking on the eye icon next to folder), and you can freely position the portal.

Portal (door display off)
Portal (door and room display off)

Above it was stated that adjacent zones should be close as possible. This is related to portal positioning. Portal - its a gap between two zones (or zone and outdoor), and it must be in both at same time. If that condition is not satisfied you will get 1 invalid portal message.

Now place another portal at the exit.

Portal (door display off)
Portal (door and room display off)

The first portal tied one room to another, but the second is connecting to open space. The difference is significant soo we need to set the Outdoor parameter to True. It indicates that the portal connects a closed space with an open space.

Portal system19.jpg

The arrows indicate on which side is the outdoor. In addition part of the portal should be inside the area and another outside of it.

Portal (door display off)

To test the portal system place a zombie statue in the corridor (Types -> Static Objects -> ZombieStatue).

Statue in the corridor

Run the simulation.

Portal system22.jpg

First go to NeoAxis Engine menu by pressing Escape. Then go to Debug menu and tick the Wireframe box, so we can see the geometry in basic mode.

Debug menu

If the zombie statue in the corridor is not seen when you are in the room, then the portal system is working correctly.

Corridor itself is visible since it is a part of Room.mesh.
Objects at corridor are not visible

Go to the door so it gets opened. If you can see the zombie statue, that means the the portal is turned on and working.

Objects at corridor are visible through a portal

We learned how to set up the portal system using zones and portal. But what of the occluders? We have already encountered an occluder when we placed a door. Add the Occluder on the map, choosing it from Base folder. But it is much easier to work with objects, that have occluders attached to them. Example is Door.type. This type consists of two attached objects: a door mesh and an occluder. There is an article about working with Resource Editor, and making objects with occluders attached, which can be found here.

Door.type