# Dynamic Radial Masks

[**Dynamic Radial Masks (DRM)**](https://assetstore.unity.com/packages/vfx/shaders/dynamic-radial-masks-144845?aid=1011lvgVb) is a shader extension for Unity, calculating world-space volumetric 3D spherical masks in a variety of forms, shapes and amounts directly inside a shader.&#x20;

Calculated result is a mask, value of *<mark style="color:blue;">float</mark>* type, which inside shader can be used for interpolating one material value into another, vertex displacement, discarding mesh fragments, creating hit and impact, rain drops, ripples, sonar and many others effects.

<div><figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FiQTxJbcmDJrI05dixqKl%2FYouTube_1280x720%20(2)%20-%202.png?alt=media&#x26;token=705b75b0-44dd-4c0a-8ed9-3cafd502bac3" alt="" width="563"><figcaption><p>Force Field</p></figcaption></figure> <figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2F7xsQ0UZzagH4S5kRfD2c%2FYouTube_1280x720%20(4)%20-%202.png?alt=media&#x26;token=9cc621dd-76b3-4b4e-8fa2-63c292a6a77c" alt="" width="563"><figcaption><p>Season Change</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%2FEk9XegVLObm2NMAHg7Id%2FYouTube_1280x720%20(5)%20-%202.png?alt=media&#x26;token=6ccba277-6b85-4944-8172-e7ca0026a787" alt="" width="563"><figcaption><p>Sonar Effect</p></figcaption></figure> <figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FYV5rJArqTdIb53noqdl0%2FYouTube_1280x720%20(6).png?alt=media&#x26;token=2ca148ca-194e-4a34-bc5f-c494ba9bd742" alt="" width="563"><figcaption><p>Water Ripples</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%2FFs7c7PAw4JmFlculwoUC%2FYouTube_1280x720%20(8).png?alt=media&#x26;token=632d60a1-3809-45e7-a680-2005dff40bf1" alt="" width="563"><figcaption><p>Rain Drops</p></figcaption></figure> <figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FZxxQDoELO8KXjMax5000%2FYouTube_1280x720%20(9)%20-%202.png?alt=media&#x26;token=18ebbc95-145b-4ce4-8983-785739de69d3" alt="" width="563"><figcaption><p>Worlds Transition</p></figcaption></figure></div>

**DRM** is a shader extension and it needs to be manually integrated into a shader, made by **Shader Graph**, [**Amplify Shader Editor**](https://assetstore.unity.com/packages/tools/visual-scripting/amplify-shader-editor-68570?aid=1011lvgVb) or hand-written HLSL file. And it is quit easy.

**DRM** integrates into **Shader Graph** and [**Amplify Shader Editor**](https://assetstore.unity.com/packages/tools/visual-scripting/amplify-shader-editor-68570?aid=1011lvgVb) using just one node. That's all. No other shader coding is required:

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FQIxiMVuHAjv0DI21hepi%2FShader_Graph.png?alt=media&#x26;token=6cc9faf7-6aee-47da-a94e-9f61b2d30448" alt=""><figcaption></figcaption></figure>

Output result of the DRM node is a mask, value of *<mark style="color:blue;">float</mark>* type. In this example, it is connected to the **Base Color** block for demonstrating volumetric 3D spherical mask it creates:

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2F8bJ1vHZKFZxSzf1KDnyU%2FMask_2.gif?alt=media&#x26;token=a844c2d1-bd9b-4430-8f20-307539dad33c" alt=""><figcaption></figcaption></figure>

One DRM node can contain up to 200 mask objects. Output result is a combination of all those masks as a one *<mark style="color:blue;">float</mark>* value. Example below demonstrates ripple effect, create by one DRM node consisting of 64 objects:

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2Fdo8I1RayTpYfT53XLfTd%2FShader_Graph_2.png?alt=media&#x26;token=854b70cd-ecae-4d2a-818e-8995c0f06f12" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FMf50aU2S5w7qqEfU7TMd%2FMask_3.gif?alt=media&#x26;token=7c67b9b2-edc6-4b2b-b6ef-26361b6e5c6e" alt=""><figcaption></figcaption></figure>

**DRM** can calculate and render volumetric 3D spherical masks of 8 shapes:

<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>

Inside shader can be used multiple DRM nodes of various shapes and counts, each one for different purposes and effects. For example, shaders in the scene below use 2 DRM nodes - one for blending winter/summer textures and another node is used for sonar effect:

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FTpjK7EbKU3bKkgq8XUUA%2FMask_4-(ezgif)%20600.gif?alt=media&#x26;token=5241bfac-a978-4ab4-ad41-979965958a3d" alt=""><figcaption></figcaption></figure>

Total number of spherical masks that can be calculated inside one shader depends on the target device’s GPU and how many shader instructions it can handle. For PC and modern consoles it may be hundreds of **DRM** projections, but for mobile devices it is much less.

DRM node consists of multiple complex properties (world-space position of mask objects, their radius, intensity, noise strength, etc) that are not editable in shader and visible inside material editor, instead those properties are updated using controller script.
