skip to content

How do portals and potentially visible sets cull the rooms of an indoor level, and what does a precomputed visible set give up?

level: middleimportance: nice to knowfreq 28%

answer

  1. rooms joined by openings
  2. narrow the view to each opening
  3. precomputed per cell, looked up at run time
  4. static walls, memory, from anywhere in the cell

basics

~20 s

Portals split a level into rooms joined by openings and narrow the view to each visible opening at run time. A potentially visible set precomputes, per cell, which cells can ever be seen, trading memory and static geometry for an almost free lookup.

solid answer

~40 s

An indoor level is split into **cells** (rooms, corridors) connected by **portals**, polygons covering doorways and windows. **Portal culling** starts in the camera's cell, draws it, and for each portal inside the current view narrows the frustum to that portal's outline and recurses into the next cell; a cell reached through no visible portal is never drawn. It runs every frame, so a closing door can simply disable its portal. A **potentially visible set** (PVS) is computed offline: for each cell, the set of cells visible from **anywhere** in it, stored as a bit per cell pair. At run time you find the camera's cell and draw only its set, then frustum-cull inside it. It gives up dynamic walls, costs build time and memory, and is loose because one set serves the whole cell.

go deeper

for a junior

Recall that indoor levels are split into rooms joined by openings, and that only rooms seen through visible openings need drawing.

for a middle

Explain how portal traversal narrows the frustum at each opening and how a precomputed set is looked up per cell at run time.

for a senior

Weigh the precomputed set's memory, build time and conservatism against portal traversal, and handle doors and destructible walls with a hybrid.

for a principal

Decide whether interiors justify a separate visibility system next to general occlusion culling, given the level design pipeline and destruction plans.

## Why interiors are a special case Indoor levels are built from rooms, corridors and doorways. Walls hide almost everything, and the only way to see into another room is through an opening. That structure lets a renderer decide visibility per room instead of per object, and decide it far more cheaply than general occlusion culling. ## Cells and portals The level is divided into **cells**, convex or nearly convex spaces such as rooms and corridor segments, and **portals**, polygons that cover the openings joining two cells: doors, windows, archways. Building them can be manual (designers place portals) or automatic from the level's geometry. ## Portal culling at run time 1. Find the cell that contains the camera and draw its contents, frustum-culled as usual. 2. For each portal of that cell, test it against the current frustum. If it is outside, skip it. 3. If it is visible, **narrow** the frustum to the portal: build planes from the eye through the portal's edges, or clip a screen-space rectangle to the portal's projected bounds. 4. Recurse into the neighbouring cell with the narrowed frustum, and repeat through its portals. Each step through a doorway can only shrink the view, so far rooms seen through a chain of openings are tested against a tiny frustum and most of their contents fail. Because it runs every frame, it adapts to state: a closed door disables its portal, an opened one re-enables it. Cycles in the cell graph are harmless as long as the narrowed frustum shrinks to nothing or a recursion limit stops it. ## A worked traversal Suppose the camera stands in a hall whose open door leads to a corridor, and a window in the corridor looks into a courtyard room. The hall is drawn whole. The door is inside the view, so the frustum shrinks to the door's outline and the corridor is tested against it; only the stretch of corridor visible through the door survives. The window is inside that narrowed view, so the frustum shrinks again to the part of the window visible through the door, and the courtyard room is tested against that sliver. Rooms behind the hall's other walls are never visited at all. ## Potentially visible sets A **potentially visible set** moves the work offline: - for every cell, compute which other cells can be seen from **any** point inside it, for example by sampling points and casting rays, or by analysing the portal graph; - store the answer as one bit per pair of cells, compressed, often with run-length encoding; - at run time, find the camera's cell, look up its bits, and draw only the objects in the visible cells, frustum-culling them as usual. The run-time cost is close to zero, which made precomputed visibility attractive on slow hardware and still useful for large static interiors. ## What a PVS gives up | Concern | Portal culling | Potentially visible set | |---|---|---| | Run-time cost | traversal and frustum narrowing every frame | a cell lookup and a bit test | | Precision | exact to the current camera position | conservative for the whole cell | | Dynamic geometry | portals can be toggled | baked; walls that move or break invalidate it | | Build time | none beyond placing portals | offline computation per cell | | Memory | the portal graph | one bit per cell pair before compression | The memory grows with the square of the cell count: 10,000 cells need 100 million bits, about 12.5 MB, before compression. Destructible walls are the classic failure: the set was computed with the wall intact, so rooms behind a new hole are missing until the data is updated. A common answer is a hybrid: a PVS for the static shell, portals with on and off states for doors, and ordinary occlusion culling for open outdoor areas, where walls do not partition the world. ## Where this sits today Open worlds and GPU depth pyramids have made general occlusion culling the default for outdoor and mixed scenes, but portal graphs are still the natural fit for interiors, and the same graph can also decide which rooms to update or simulate, not only which to draw.

  • Why is a potentially visible set computed from anywhere in a cell rather than from one point?
    The camera can be anywhere in the cell at run time, and the lookup has no idea where, so the set must include every cell visible from any position inside it. That makes the set conservative: from a particular spot, some listed cells are actually hidden and get drawn for nothing.
  • How do doors fit into portal and visible-set culling?
    In portal culling a door is a portal with an open or closed state, so a closed door simply stops traversal. A precomputed set often treats doors as open when it is built, and then uses the run-time portal state to drop cells only reachable through closed doors.

Standing in a hallway, you see the next room only through its doorway, and a room beyond only through a doorway that is itself visible through the first. Portal culling follows the same chain, narrowing the view at every opening.

  • A precomputed visible set handles destructible walls automatically.
  • Portal culling needs an offline precomputation step for every room.
  • A visible set stores what is visible from the cell's centre point.
  • Passing through a portal widens the view frustum.
  • Portals and visible sets suit open outdoor terrain as well as interiors.