# Camera Dither Fade

In most games, an object occurring between the character and camera will be _dithered out_, or _fading out_, according to the duration it blocks the character.

ComponentCameraSystem offers an easy way to setup camera dither fade. Just follow the next steps:

1. Create a new blueprint class inherting the `EPlayerCamaraManager` class:

<figure><img src="https://1253177398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIc7aRtmwmEkkqEJZORmC%2Fuploads%2F1CuYpugx8llcnK9tS48V%2Fmyplayemanager.png?alt=media&#x26;token=86177bff-ce48-418c-b4aa-9935e346b904" alt=""><figcaption></figcaption></figure>

2. Open the blueprint class you just created and you can see several parameters in the Dither section. Tweak them according to your needs. An introduction to these parameter is presented at the end of this page. When you finish, don't forget to set this class in your player controller.&#x20;

<figure><img src="https://1253177398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIc7aRtmwmEkkqEJZORmC%2Fuploads%2FspmtuTjyZDL455s8piJr%2Fdither.png?alt=media&#x26;token=a9857616-0d35-448a-8057-c893b0e43c31" alt=""><figcaption></figcaption></figure>

3.  The next step is to setup the materials you want to apply dither fade to.&#x20;

    * For the player character, go to the main material (e.g., the M\_Mannequin material in UE5) and connect to the Opacity Mask node as follows:

    <figure><img src="https://1253177398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIc7aRtmwmEkkqEJZORmC%2Fuploads%2FqAGsvQ0EtnS1njbZn11T%2Fcharacterdither.png?alt=media&#x26;token=b393c71f-598e-479e-9044-1a750edaedd7" alt=""><figcaption></figcaption></figure>

    That is, first create a scalar parameter named **EFadeWeight** (mandatory name) and set its default value as zero; then substract it with 1 followed by a DitherTemporalAA node. Finally connect it to Opacity Mask.

    * For other materials including foliage, buildings, etc, do the same thing and connect to the Opacity Mask pin. But for some materials, you should first set the _Blend Mode_ to **Masked** because the Opacity Mask pin shows up only in the Blend Mode.

    <figure><img src="https://1253177398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIc7aRtmwmEkkqEJZORmC%2Fuploads%2FdVmSU9heu1SifxQnRd31%2Fblendmode.png?alt=media&#x26;token=1e1bd282-9a92-4e19-a25c-be19c8cc66df" alt=""><figcaption></figcaption></figure>

    <figure><img src="https://1253177398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIc7aRtmwmEkkqEJZORmC%2Fuploads%2FgWyeCt2BizGJDpyzSL2x%2Fmaterialdither.png?alt=media&#x26;token=1b65bbac-fda8-449c-a40e-d18e37272f16" alt="" width="563"><figcaption></figcaption></figure>

    Remarks: Dither fade now only supports **Masked** materials. For materials that cannot be set as **Masked** blend mode, I recommend using [ResolveOcclusionExtension](../camera-components/extension-components/resolveocclusionextension).
4. Now enjoy the nice dithering effect!

![](https://1253177398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIc7aRtmwmEkkqEJZORmC%2Fuploads%2FKyCOwwK3W7ID4mqWzUpd%2Fselfdither.png?alt=media\&token=72448fd3-b3c2-4a4e-81df-99c137a35e5c)![](https://1253177398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIc7aRtmwmEkkqEJZORmC%2Fuploads%2FdRJ39ctmIujNwrqIlO5z%2Fobjdither.png?alt=media\&token=9d068bd6-6de4-4cde-a5bd-17edc7889abc)

**Known issue**: The DitherTemporalAA node can result in an issue under some occasions: it causes low-bit shadow artifacts, as shown below. If you really care about this issue, maybe you should avoid using this feature, and I will attempt to deal with it in the Beta version.

<figure><img src="https://1253177398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIc7aRtmwmEkkqEJZORmC%2Fuploads%2FE1ctKSE6wfDdzYnzywx7%2Fditherbug.png?alt=media&#x26;token=6d947cfe-6d58-4812-80bb-fc7cbcb3e852" alt="" width="439"><figcaption></figcaption></figure>

**Update 1**: You can partly solve this issue by adding a ShadowPassSwitch node right after the DitherTemporalAA node to have shadows opaque. The downside is that if you do so, the shadows will never disappear even if the object itself turns fully transparent.

<figure><img src="https://1253177398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIc7aRtmwmEkkqEJZORmC%2Fuploads%2FyewxM8fKILSAzoCMAaKA%2Fshadowpassswitch.png?alt=media&#x26;token=b35590b2-3ff6-4c01-818d-8a105f42ff0f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1253177398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIc7aRtmwmEkkqEJZORmC%2Fuploads%2F8YFJpQaFWP4AOjmBCEEF%2Fresult.png?alt=media&#x26;token=3d46cb54-7cf3-47d9-90c9-37d88c47a48a" alt=""><figcaption></figcaption></figure>

Descriptions of dither paramerters:

<table><thead><tr><th width="142.33333333333331">Parameter</th><th width="145"></th><th>Description</th></tr></thead><tbody><tr><td>Enable Dither</td><td></td><td>Whether to enable dither fade.</td></tr><tr><td>Dither Fade Params</td><td></td><td>A set of parameters defining dither behaviours.</td></tr><tr><td></td><td>Object Types</td><td>Array of object types of actors that should be taken into account for fade. Note that this parameter should exclude the type of self, which is usually Pawn.</td></tr><tr><td></td><td>Actors Types to Ignore</td><td>Actor types to ignore for fade.</td></tr><tr><td></td><td>Actors to Ignore</td><td>Actors ignored for fade.</td></tr><tr><td></td><td>Sphere Radius</td><td>Sphere radius for tracing objects.</td></tr><tr><td></td><td>Max Trace Length</td><td>Maximum trace length. Set as 0 to use the length from camera to target.</td></tr><tr><td></td><td>Enable Self Dither</td><td>Whether to enable self dither fade.</td></tr><tr><td></td><td>Self Type</td><td>Object type of self, usually Pawn.</td></tr><tr><td></td><td>Dither Self Trace Length</td><td>Trace length for dither fading the controlled pawn (self).</td></tr><tr><td></td><td>Dither Self Max Weight Distance</td><td>Distance determining max dither weight. If camera-hit distance is less than this value, weight of self dither would be the largest.</td></tr><tr><td></td><td>Show Debug</td><td>Whether to show debug info.</td></tr><tr><td>Max Weight</td><td></td><td>Maximum dither fade weight. 1 represents fully faded.</td></tr><tr><td>Dither Fade In Time</td><td></td><td>Fade in time.</td></tr><tr><td>Dither Fade Out Time</td><td></td><td>Fade out time.</td></tr><tr><td>Dither Tick Interval</td><td></td><td>Tick interval, in seconds. Large values save more performance but will result in lagging.</td></tr></tbody></table>
