# Tutorial #4 - Ripples

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FKVdzIauHpA34HJuKbtLn%2F6.mp4?alt=media&token=d196ff4f-060d-4d61-8367-c218f767fbd8>" %}

For creating ripple effect we have to use DRM node with multiple mask objects and **DRM Live Objects** for self-animating DRM properties.

{% stepper %}
{% step %}
Create DRM node with **Torus** shape and with **Count** of 64:

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2F7LiTUyCrwpyi0Dj012F4%2F22.png?alt=media&#x26;token=feff1b1c-4617-43c2-b243-e7f5cc8093d7" alt="" width="345"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Create new **Shader Graph** file and drag and drop generated DRM node there and connect its output to the **Base Color** block. Create new material using this shader:

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FvJDMclvPvJOLSxbLkhln%2F23.png?alt=media&#x26;token=9420a52d-94bf-4d37-8866-a15f6ade33fe" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Create **DRM Controller** with the same settings and add ripples material to the **Materials** array and switch **Pool** to **Live Objects**:

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FKtxCMlaDgXFPqpZlxJ5h%2F24.png?alt=media&#x26;token=570f53b3-b680-4482-a0de-a4321db74bec" alt="" width="285"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Create Plane mesh (any mesh can be used). Assign ripples material to it and add **DRM On Mouse Raycast** script with following settings:

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2Fk70X5xi4rGe3ApIln8mz%2F25.png?alt=media&#x26;token=25ab9388-7b48-4c68-a6ac-dae02396745a" alt="" width="357"><figcaption></figcaption></figure>

{% hint style="success" %}
Pay attention how **DRM Live Objects** settings are animated during life-time:

* **Life Length** of each object is between 1.5 and 3 secs.
* **Radius** property at the beginning is 0.2 and by the end of life-time reaches random size between 0.8 and 1.5
* **Intensity** is animated using a Curve, where its value is 0 at the beginning and in the middle of life-time reaches 1, then it smoothly decreases to 0 again.

![](https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FJAaO8AYHjU6B9wPzlZZm%2F26.png?alt=media\&token=c9c22e45-e045-4b85-b78e-eabb50d928b1)

{% endhint %}
{% endstep %}

{% step %}
Enter game mode and click on the mesh. **DRM live objects** should be generated on the Plane surface:

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2Ffv4TBi38DtIpOYVumzE0%2F10.mp4?alt=media&token=6024111f-0f50-4f05-a510-d208c02696d5>" %}
{% endstep %}

{% step %}
Adjust shader to calculate *<mark style="color:blue;">normals</mark>* from the DRM node value:

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FWvRq6QWtz8DWNECoKm4e%2F27.png?alt=media&#x26;token=8470ebc3-d358-40f0-8f17-f017f8f1dfc1" alt=""><figcaption></figcaption></figure>

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FKAsFZJf4Xn0mJfki9fQd%2F11.mp4?alt=media&token=ace5ec28-b04a-4897-b59e-098c0fef4958>" %}
{% endstep %}

{% step %}
For creating displacement effect DRM node can be used inside vertex stage too:

<figure><img src="https://1494537888-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FTg3af7ncgXMyz46qjyp3%2F28.png?alt=media&#x26;token=ed4e6438-11ea-438c-94e6-645aff4474d9" alt=""><figcaption></figcaption></figure>

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVDsGRBXgFisq0hO6tTXv%2Fuploads%2FKVdzIauHpA34HJuKbtLn%2F6.mp4?alt=media&token=d196ff4f-060d-4d61-8367-c218f767fbd8>" %}

{% hint style="info" %}
Note, for creating smooth vertex displacement effect use tessellation or mesh with high vertex density. Built-in plane mesh with 10x10 vertices may not be suitable. For this case, package includes plane mesh with 100x100 and 500x500 vertices.&#x20;
{% endhint %}

{% hint style="warning" %}
Using the same DRM node in the pixel and vertex stages is not possible if for **Noise** input is used the [Texture Sampler 2D](https://docs.unity3d.com/Packages/com.unity.shadergraph@14.0/manual/Sample-Texture-2D-Node.html) node, as for vertex stage should be used [Sample Texture 2D LOD](https://docs.unity3d.com/Packages/com.unity.shadergraph@14.0/manual/Sample-Texture-2D-LOD-Node.html) node. In this case duplicate DRM node and use appropriate texture sampler node with each one.
{% endhint %}
{% endstep %}
{% endstepper %}
