Skip to content

Integrations: SECTR Portal Culling

DunGen provides built-in integration with SECTR, a powerful portal-based visibility culling system available on the Unity Asset Store. This integration automatically generates SECTR Sectors and Portals based on your DunGen Tile layout, helping to significantly improve rendering performance by culling rooms (Sectors) that are not visible through doorways (Portals).

Third-Party Asset Required

SECTR is a separate asset available on the Unity Asset Store and must be purchased and imported into your project before setting up this integration.


Prerequisites

  1. Install SECTR World Straming into your Unity project from the Asset Store.
  2. Ensure the DunGen integration scripts are available. If you haven't already, navigate to Assets/DunGen/Integration/ in your Project view and double-click the SECTR_VIS.unitypackage file to extract its contents.

Setup

Setting up the integration is straightforward:

  1. Locate the GameObject in your scene that has the Runtime Dungeon component attached.
  2. Add the SECTR VIS Portal Culling Adapter component to this same GameObject (Add Component > DunGen > Culling > SECTR VIS Portal Culling Adapter).
  3. Select your main Player Camera GameObject.
  4. Add the SECTR Culling Camera component to your Player Camera (Add Component > Procedural Worlds > SECTR > Vis > SECTR Culling Camera).

That's it! The DunGen adapter will now run automatically during the post-processing phase after dungeon generation.


Adapter Component Settings

The SECTR VIS Portal Culling Adapter has a few settings:

  • Priority: Determines the execution order if multiple DunGen adapters are present. Usually, the default (-1, often running after pathfinding) is suitable.
  • Directional Shadow Caster: (Optional) Assign your main directional light here if you want SECTR to manage shadow culling based on Sector visibility.
  • Extra Bounds: Allows you to add padding to the automatically calculated Sector bounds.
  • Cull Each Child: Determines SECTR should cull child Sectors individually or if culling is done based solely on the single Sector for the Tile.

SECTR Documentation

For detailed explanations of these SECTR-specific settings (Directional Shadow Caster, Extra Bounds, Cull Each Child), please refer to the official SECTR documentation.


Runtime Behaviour

Once set up:

  1. DunGen generates the dungeon layout.
  2. During post-processing, the SECTR VIS Portal Culling Adapter runs.
  3. The adapter automatically creates:
    • A SECTR Sector component for each Tile instance in the dungeon.
    • A SECTR Portal component spanning each connected Doorway between Tiles.
  4. The SECTR Culling Camera on your camera then uses this Sector and Portal information to perform visibility culling each frame.

Handling Doors

To allow doors to dynamically open and close, affecting visibility:

  1. Ensure your door prefabs (used as Connectors or via the Lock & Key system) have a script attached that includes a Door component.
  2. This script must correctly set the Door component's IsOpen property to true when the door is open and false when it's closed.

The DunGen integration automatically configures the generated SECTR Portal components to check the IsOpen status of the associated Door component. When IsOpen is false, the portal will be closed, and SECTR VIS will cull the Sector behind it. When true, the portal opens, allowing SECTR VIS to potentially render the Sector beyond.


Using the SECTR VIS integration is an effective way to boost rendering performance in your DunGen-powered levels, especially in complex interior environments.