# Occlusion

Flora supports two forms of occlusion culling: **GPU-based dynamic occlusion** and **Unity’s CPU-based baked occlusion**. Both systems help skip rendering instances that are not visible to the camera, improving performance in scenes with overdraw or high instance counts.

***

### GPU Dynamic Occlusion

Flora’s GPU occlusion system uses **compute shaders** and the **previous frame’s depth buffer** to determine visibility. Occluded instances are skipped during rendering.

#### Performance Considerations

* In scenes with **significant occlusion** and **high-vertex instances**, GPU occlusion can greatly reduce rendering cost.
* In scenes with **minimal occlusion**, the extra compute pass may **increase** GPU load unnecessarily.

> GPU occlusion is **scene-dependent** — always profile with and without it to measure the impact in your project.

#### Compatibility with [GPU Resident Drawer](/rendering/gpu-resident-drawer.md)

If you're using Unity’s **GPU Resident Drawer**, be aware:

* Flora and GPU Resident Drawer each maintain **separate occlusion resources.**
* Both systems perform **their own depth sampling passes.**
* This can result in **redundant GPU work**, particularly on lower-end hardware.

> **Recommendation:** Use **only one** GPU occlusion system per scene to avoid unnecessary overhead.

***

### Usage

GPU occlusion is **enabled by default**, but can be configured at multiple levels:

* **Project-wide:**\
  Via [`FloraRuntimeSettings`](/scripts/runtime-settings.md) → *Disable GPU Occlusion*
* **Per Scene:**\
  Via [`FloraSceneSettings`](/scripts/scene-settings.md) → *Allow GPU Occlusion*
* **Per Camera:**\
  Via [`FloraAdditionalCameraSettings`](/scripts/instancing-camera-settings.md) → *Allow GPU Occlusion*

***

### CPU Baked Occlusion

Flora also supports Unity’s built-in **CPU-based occlusion culling**, which uses pre-baked visibility data to cull geometry blocked by static objects.

#### Advantages

* Ideal for **lower-end platforms** (e.g., mobile) where GPU compute may be too costly.
* Requires **no runtime compute passes.**
* Automatically used by Flora if baked occlusion data is present in the scene.

#### Setup

No special configuration is needed.

As long as occlusion data is baked using Unity's built-in tools, Flora will use it automatically.

For more information, see Unity’s [Occlusion Culling documentation](https://docs.unity3d.com/Manual/OcclusionCulling.html).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://flora.magneticarcade.com/rendering/occlusion.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
