PORTALIZATION

VISIBILITY

For optimal visualization performance you can use the portal based run-time hidden surface removal system. In order for the engine to be able to reject hidden surfaces effectively in the run-time, a map needs to be divided into separate areas that are called clusters. Clusters are separated from each other by walls and portals. The walls that are built from opaque materials are automatically a barrier for clusters but portals need to be placed manually.
If visualization performance is satisfying it is not necessary to use portals and you can skip this chapter.

STRUCTURAL GEOMETRY

Structural geometry is objects that are opaque to the visibility system so, in conjunction with portals, they are a barrier for a Cluster. A Cluster barrier can be:

  • a Block automatically if its material is opaque and it is not a part of a group (can be a part of a helper group).

  • a Model if it has its structural property set to true and it is not a part of a group (can be a part of a helper group).

Because a Block is a convex hull it always cuts away a certain region of space. A model on the other hand is a set of triangles and has open edges or can have zero thickness elements (e.g. two walls in front of each other or facing each other in the same place). Such a model should not be used as structural geometry because that can result in hard-to-predict classification of different space regions as transparent or opaque for visibility system. A structural model should:

  • close a region of space by its mesh – it should not have any open edges;

  • not have triangles (walls) facing each other in the same place – the region of space it encloses should always have a none zero thickness.

It is possible to break those rules and to use a model with open edges as a structural element. If you do so, you have to place those models in a map in such a way that none of the open edges is in the area that should be accessible in visualization.

Structural geometry divides a map into solid areas – that are opaque to the visibility system and empty areas that can bee seen through. A map that is structured into solid and empty regions (by structural geometry) can be divided into clusters with the use of portals.

In practice, structural geometry is automatically created from Blocks, and when models are used as walls you just have to mark certain modes as structural and, if it is necessary, stop all leaks with solid material Blocks.

PORTALS

Portals are a barrier for the visibility system and they divide empty space into clusters. In order to divide space into two separate clusters you need to separate areas with portals accurately. The Vacation House project example may serve as an example of portal usage .

The purpose of dividing a map using clusters is to generate information that the rendering engine can use in real time to decide what is visible at a particular moment. This is because of the properties of clusters:

Because of that, portal placement has a significant impact on performance. There is no general rule that describes how portals should be placed. Examining a map with the show edges option enabled and trying to figure out if placing a new portal would enable the visibility system to reject currently rendered objects (you can see the objects that have been overdrawn because their edges are rendered without z-buffering). In practice, portals are placed in:

  • door frames,

  • windows,

  • passageways between different levels of buildings (stairs),

  • corridors and rooms with complicated (non-convex) shapes – look at the examples below.

To create a portal, create a Block with the portal material. Portals are created from all sides of a Block. If you want to create only one portal, use the void material on all sides of the Block except the one you want to create a portal with.

Doors (and other groups) can block portals. For information about how to block portals refer to the tutorial on creating doors.

CLUSTERS

Clusters are build by the map compiler while a map is being compiled. The process starts by finding a position of some object (a light, an actor, a target) and clusters are built starting from that position. If a map has no appropriate objects, then the 0, 0, 0 position is used. If 0, 0, 0 is inside a solid area, the map cannot be compiled. A cluster space is separated from other clusters by structural geometry and portals (portals are built in the example below):

Flow Architect Studio 3D portalizing1 How to place portals

If even a small hole exists between areas that you want to separate, clusters will not be separated and one cluster will be created:

Flow Architect Studio 3D portalizing3 How to place portals

In practice it is sometimes hard to control all small holes in a map, and create clusters in an intended way. Unintended passages (cracks or holes) between areas that were meant to be separated are called leaks.

LEAKS

There are two kinds of leaks:

  • Leaks between areas that were intended to be separate and that we intended to create separate clusters with.

  • Leaks from a cluster to the outside of a map – in the case of such a leak, the map compiler will not remove the external parts of the map (the parts that will never be accessed.

Flow Architect Studio 3D portalizing2 How to place portals

As you can see, if nothing outside can be seen from the inside, the map compiler can remove the external parts of the map. This is also true for all other inaccessible areas.

DEALING WITH LEAKS

Finding leaks can be difficult. The first step is to test if clusters were created in the way they were intended. To test how a cluster was created check Show cluster portals options on the Control Panel in Performance tab. This option will show all portals of the cluster that camera is currently in. If you can see portals that were not meant to be in the cluster you are in, it means that it is most probable that there is a leak. The next thing you can do is choose the Show edges option from the Control Panel Performance tab. This will show the edges of all things that are currently drawn. This allows you to see if a part of the map that should not be drawn, provided there are no leaks, is being drawn.

To find leaks you can use a tool built in the engine, which finds such a path between two different points in space that does not cross any portals. To find a leak, do the following test. Position the camera in the first point and press Set leak test start point button from the engine Control panel on the Leaks tab. The engine will set the leak test start point in the current camer
a position. Then move the camera to another location and press the
Set leak test end point button. The engine will set the leak test end point in the current camera position and the Do leak test option will be enabled. Press the Do leak test button to execute the leak test. A path, if found, that connects the start and end points (the path might not be optimal) and does not cross any portal will be drawn. Follow the line to locate a leak between the different areas you test.

How to place portals