# DRM Settings & Editor Window

Before using DRM inside shader appropriate DRM effect needs to be generated inside editor. It is done by using DRM editor window from <mark style="color:blue;">**Unity Main Toolbar**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">→</mark> <mark style="color:blue;"></mark><mark style="color:blue;">**Window**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">→</mark> <mark style="color:blue;"></mark><mark style="color:blue;">**Amazing Assets**</mark> menu:

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FUAMkKY6s4CoAVaZlMCRY%2F13.png?alt=media&#x26;token=c425e817-baa1-459f-85bb-494759202e5d" alt="" width="344"><figcaption></figcaption></figure>

{% tabs %}
{% tab title="Shape" %}
Shape of a volumetric mask. **DRM** can calculate and render 3D spherical masks of 8 shapes. Each one uses its own calculation algorithm and has different performance cost in the terms of instructions count:

<div><figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FxF7CHW90fsUjKb1ZMgol%2FTorus.png?alt=media&#x26;token=6d5f248b-8bd0-4252-bc3a-35613d5d659f" alt=""><figcaption><p><strong>Torus</strong></p></figcaption></figure> <figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2F6QoLTVoScH2mSBlM6kag%2FTube.png?alt=media&#x26;token=defa07fa-9dbd-4dc8-af88-0ba7555ea4e9" alt=""><figcaption><p><strong>Tube</strong></p></figcaption></figure> <figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2Fub15SODx1zhWhxOczoz6%2FHeight%20Field.png?alt=media&#x26;token=1b5b53ce-d936-4a6a-8ff7-c1aec78fd68c" alt=""><figcaption><p><strong>Height Field</strong></p></figcaption></figure> <figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FCBUtPnACLlFqmS4KHK0u%2FDot.png?alt=media&#x26;token=4ddd6cf6-7fe9-4b6d-a523-3878eaf13d8c" alt=""><figcaption><p><strong>Dot</strong></p></figcaption></figure></div>

<div><figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FbKENjafzoUhm9wGYYAQM%2FShockwave.png?alt=media&#x26;token=daf06100-1361-433e-89dd-8ad83c11fa66" alt=""><figcaption><p><strong>Shockwave</strong></p></figcaption></figure> <figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2Fp3R4CcZo2hRpYy3WLhel%2FSonar.png?alt=media&#x26;token=d68e6a20-8ea4-4c7e-8ab0-01a928673b96" alt=""><figcaption><p><strong>Sonar</strong></p></figcaption></figure> <figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FsM69f6cusETY0tMvn9Qy%2FRings.png?alt=media&#x26;token=6ba0cb45-2ab8-4ad9-9b69-e9423ae5e000" alt=""><figcaption><p><strong>Rings</strong></p></figcaption></figure> <figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FDTctAHg48qhLZSwFk9AJ%2FRipple.png?alt=media&#x26;token=c978797a-7817-428d-b010-fceb3fde4336" alt=""><figcaption><p><strong>Ripple</strong></p></figcaption></figure></div>
{% endtab %}

{% tab title="Count" %}
Defines spherical projections count calculated and rendered by one DRM node. Performance cost of the DRM method depends on this value. More masks it calculates, the more expensive it is, and shader becomes slow.

{% hint style="danger" %}
When using DRM inside a shader, take note that various GPU’s have different limitations on the shaders instructions count and **Count** parameter must be kept as low as possible. While high-end GPU can render hundreds of DRM elements, the same shader may fail to compile on the mobile devices or it may be very slow.
{% endhint %}
{% endtab %}

{% tab title="Type" %}
DRM calculation method type:&#x20;

* **Simple** - Fast mask calculation method. Requires less instructions, but doesn't support  **Smooth** and **Noise** features.&#x20;
* **Advanced** - Mask rendering requires more instruction, but supports all visual features.

Chart below displays shader instructions count comparison of **Advanced** and **Simple** types:

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2F8NM1bNJS05REqEyb3X1b%2F29.png?alt=media&#x26;token=c9364149-d2bf-49b7-b706-3614bd52d63d" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="info" %}
Just a note, **Gradient Noise** node from the **Shader Graph** uses 133 instructions:

![](https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FXNwhUnjJNj4zSwzGvrL9%2F30.png?alt=media\&token=fcb1daaa-4a45-4769-a68e-b91df5327af2)
{% endhint %}
{% endtab %}

{% tab title="Blend Mode" %}
DRM uses *<mark style="color:blue;">for loop</mark>* cycle for calculating mask consisting of multiple objects and **Blend Mode** defines how results of those iterations are combined:

* **Additive** - Adds the result of the current iteration to the previous. For example, on the image below is demonstrated a mask consisting of two projections. If the **Intensity** values of those projections are, for example 3 and 4, then the intensity at the intersection zones for the final resultant mask will be 7. Additive blend mode is useful in cases where shader effect depends on the intensity of the resultant mask, for example, in the vertex displacement effects. Depending on the DRM properties (especially **Intensity** value), output of the DRM node may be in the range of \[-∞, +∞]. Always use **Saturate** or **Clamp** results of the additive DRM node before using them with the **Lerp** or similar methods.

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FAx1GanLNbFJ1iZOKWj0V%2F31.png?alt=media&#x26;token=b33cd01f-ba92-4e5d-a69c-31d892d4efb2" alt="" width="375"><figcaption></figcaption></figure>

* **Normalized** - Inside *<mark style="color:blue;">for loop</mark>* cycle each mask is smoothly blended with previous one and  output of the DRM node always is in the range of \[0, 1].&#x20;
  {% endtab %}

{% tab title="ID" %}
If inside a shader it is necessary to use several identical DRM nodes, but each one with its own properties and use case, then using **ID** property can be generated alternative variants of the same DRM node.
{% endtab %}

{% tab title="Scope" %}
Defines scope of the DRM properties inside a shader:

* **Local** - DRM properties belong only to a specific material instance and affect only that material or renderer. If scene contains multiple materials using the same DRM node, each material can be updated using a single **DRM Controller** (in this case DRM properties will be the same for all materials) or each material can be updated separately using its own **DRM Controller**.&#x20;
* **Global** - DRM properties are set only once (using **DRM Controller**) and they are automatically visible to all shaders and materials that reference them. In the example below all scene materials use the same DRM node for rendering Sonar effect and its properties must be the same for all of them, so why update those properties for each material individually, when it is possible to update them just once and all materials will automatically use them:

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FsRFdyeQffTGzJGra62co%2F12.mp4?alt=media&token=4899e523-5113-4ba4-98dc-136789c466b4>" %}
{% endtab %}
{% endtabs %}

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2F8HZaxboI8MAMLXeDvrQO%2F32.png?alt=media&#x26;token=366095d9-cd60-4869-8f10-28d31596a794" alt="" width="337"><figcaption></figcaption></figure>

After choosing DRM settings clicking on the one of 3 shader editor buttons, generates required DRM files and highlights them inside the **Project** window, that can be drag & dropped inside shader editor or used in HLSL files:

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FdibuNMzNrk6cyrR6Sja8%2F2.png?alt=media&#x26;token=7124bee9-e605-49c9-81f7-d20affce58d9" alt="" width="563"><figcaption></figcaption></figure>
