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:
-
Create a shader graph (URP or HDRP depending on the render pipeline you are using) and open it for editing.
-
Add the
Compute Deformation
node to the Shader Graph. -
Connect position, normal, and tangent output ports for the
Compute Deformation
node to the corresponding input ports of the master node. -
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:
-
Create
Amplify Shader
and open it for editing. -
Open the
Add Node
dialog (Space
orRight Click
) and add theRukhanka
->Compute Deformation
node. -
Add
Vertex Data
->Vertex ID
node. -
Connect the
Out
port of theVertex ID
node with theVertex ID
port of theCompute Deformation
node. -
Connect the
Deformed Position
port of theCompute Deformation
node with theVertex Offset
port of the shader master node. -
Connect the
Deformed Normal
port of theCompute Deformation
node with theVertex Normal
port of the shader master node. -
Connect the
Deformed Tangent
port of theCompute Deformation
node with theVertex Tangent
port of the shader master node. -
Select the shader master node and enable the
DOTS Instancing
option, and setVertex Position
toAbsolute
.