# Occlusion Vision

## Solution Overview

* This solution implements an occlusion-aware rendering system built on the URP framework, capable of displaying silhouettes of objects behind occluders.
* The effects are customizable. It comes with several built-in occlusion effects and supports user-defined custom effects.
* It's simple to use; just place the system's prefab into your scene, and it's ready to go.
* It has a low performance overhead, supports batching, and uses lightweight shaders, making it suitable for mobile platforms.

## Feature Support

* Supports configuring the LayerMask and Color for objects with occlusion effects.
* Supports grouping, allowing different groups to have unique configurations and styles.
* Includes several built-in standard occlusion effects.
* Allows for custom occlusion effects using user-defined shaders.

## Built-in Effects

* SolidColor
* DitherPattern
* Fresnel
* Outline

## How to Use

* Copy the `OcclusionVision` Prefab from the package.
* Configure the prefab's parameters and add it to your scene.
* You can create different copies to meet the needs of various scenarios.

<figure><img src="https://1015306288-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5TKI5zdwMx1bXFiVnBUe%2Fuploads%2FmtQTsJEWu8DZ8W7ACqXx%2F%E5%9B%BE%E7%89%871.png?alt=media&#x26;token=1d63dafd-6aa0-43ea-8a96-f2f25adf30be" alt=""><figcaption></figcaption></figure>

## Parameter Description

* LayerMask: Specifies which objects should have the occlusion effect applied.
* Color (RGBA): The color of the occlusion effect (supports transparency).
* Intensity: The intensity of the occlusion effect's color.
* Shader: The shader that implements the occlusion effect. Built-in effects will set this automatically, while custom effects require manual assignment.

## Custom Effects

* Refer to `CustomExample.shader` for guidance on writing your own shader.
* Configure the `Occlusion Vision Group` parameters:
  * Style: Select `Custom`.
  * Shader: Assign your custom shader.

<figure><img src="https://1015306288-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5TKI5zdwMx1bXFiVnBUe%2Fuploads%2FqYi6iyEg6ynItdUIqFE3%2F%E5%9B%BE%E7%89%872.png?alt=media&#x26;token=cb88f410-1ba9-4ebc-b079-033313d6b5d9" alt=""><figcaption></figcaption></figure>

## Performance Details

* Batch count will increase, but it supports SRP batching.
* Batching Overhead: `SolidColor` = `Fresnel` = `DitherPattern` < `Outline` (Low)
* Shader Overhead: `SolidColor` (Very Low) < `Outline` (Low) < `Fresnel` (Low) < `DitherPattern` (Medium)
* Recommended for use on a reasonable number of objects, not hundreds or more.

## Performance Scaling

* Very Low: Disable the effect if there are more than 10 occluded objects.
* Low: Disable the effect if there are more than 50 occluded objects.
* Medium: Disable the effect if there are more than 100 occluded objects.
* High: Disable the effect if there are more than 200 occluded objects.
* Flagship: Disable the effect if there are more than 300 occluded objects.

## Enjoying this package? <a href="#lmfg-1756996814992" id="lmfg-1756996814992"></a>

* Give it a quick rating or leave a short review on the Unity Asset Store.
* Your feedback helps us improve and add even more features!
* [Review on Unity Asset Store](https://assetstore.unity.com/packages/slug/327956)


---

# 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://graphicscat.gitbook.io/graphicscat/documentation/occlusion-vision.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.
