Skip to main content

Shaders with Deformations

For the correct rendering of skinned meshes deformed by Rukhanka, an ECS deformation-aware shader should be created. To make this task Unity Shader Graph or Amplify Shader Editor tool can be used.

Unity Shader Graph

Creating deformation-compatible shaders using Unity Shader Graph is straightforward. The whole process is described in detail in mesh deformation section of official Entities Graphics documentation. The process consists of several simple steps:

  1. Create a shader graph (URP or HDRP depending on the render pipeline you are using) and open it for editing.

    Create shader graph

  2. Add the Compute Deformation node to the Shader Graph.

    Add compute deformation node

  3. Connect position, normal, and tangent output ports for the Compute Deformation node to the corresponding input ports of the master node.

    Final Shader Graph

  4. Save and assign this newly created shader to the materials of skinned mesh renderers.

Amplify Shader Editor

Amplify Shader Editor tool has no Entities.Graphics compute deformation support out of the box, but Rukhanka adds necessary functionality to it. The process of creating deformation aware shader in Amplify Shader Editor is also simple:

  1. Create Amplify Shader and open it for editing.

    Create Amplify Shader

  2. Open the Add Node dialog (Space or Right Click) and add the Rukhanka->Compute Deformation node.

    Create Deformation Node

  3. Add Vertex Data->Vertex ID node.

  4. Connect the Out port of the Vertex ID node with the Vertex ID port of the Compute Deformation node.

  5. Connect the Deformed Position port of the Compute Deformation node with the Vertex Offset port of the shader master node.

  6. Connect the Deformed Normal port of the Compute Deformation node with the Vertex Normal port of the shader master node.

  7. Connect the Deformed Tangent port of the Compute Deformation node with the Vertex Tangent port of the shader master node.

    Connected Ports

  8. Select the shader master node and enable the DOTS Instancing option, and set Vertex Position to Absolute.

    Final ASE Shader