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
- Install SECTR World Straming into your Unity project from the Asset Store.
- Ensure the DunGen integration scripts are available. If you haven't already, navigate to
Assets/DunGen/Integration/in your Project view and double-click theSECTR_VIS.unitypackagefile to extract its contents.
Setup
Setting up the integration is straightforward:
- Locate the GameObject in your scene that has the
Runtime Dungeoncomponent attached. - Add the
SECTR VIS Portal Culling Adaptercomponent to this same GameObject (Add Component > DunGen > Culling > SECTR VIS Portal Culling Adapter). - Select your main Player Camera GameObject.
- Add the
SECTR Culling Cameracomponent 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:
- DunGen generates the dungeon layout.
- During post-processing, the
SECTR VIS Portal Culling Adapterruns. - The adapter automatically creates:
- A
SECTR Sectorcomponent for eachTileinstance in the dungeon. - A
SECTR Portalcomponent spanning each connectedDoorwaybetween Tiles.
- A
- The
SECTR Culling Cameraon 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:
- Ensure your door prefabs (used as Connectors or via the Lock & Key system) have a script attached that includes a
Doorcomponent. - This script must correctly set the
Doorcomponent'sIsOpenproperty totruewhen the door is open andfalsewhen 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.