Shaders with Deformations
For the correct rendering of skinned meshes deformed by Rukhanka, a deformation-aware shader should be created.
To make this task Unity Shader Graph
, Amplify Shader Editor
, or Better Shaders
tool can be used.
Entities.Graphics
deformation shader usage is deprecated with Rukhanka Animation and its support will be removed in future releases
Sample deformation-compatible shaders can be found in Rukhanka samples
Unity Shader Graph
Creating deformation-compatible shaders using Unity Shader Graph
is straightforward:
-
Create a shader graph (URP or HDRP depending on the render pipeline you are using) and open it for editing.
-
Navigate to the
Packages/Rukhanka Animation System 2/Rukhanka.Editor/ShaderGraph/
folder in the project inspector window. -
Add
Rukhanka Deformation
subgraph to the createdShaderGraph
by dragging and dropping it from the project inspector. -
Connect position, normal, and tangent output ports of the
Rukhanka Deformation
node to the corresponding input ports of the master node. -
Create two shader parameters:
-
_DeformedMeshIndex
with typefloat
. -
_DeformationParamsForMotionVectors
with typeVector4
.Make both parameters declared as
Hybrid Per Instance
.
- Save and assign this newly created shader to the materials of skinned mesh renderers.
Amplify Shader Editor
The process of creating deformation aware shader in Amplify Shader Editor
is also simple:
-
Create
Amplify Shader
and open it for editing. -
Navigate to the
Packages/Rukhanka Animation System 2/Rukhanka.Editor/AmplifyShaderEditor/
folder in the project inspector window. -
Add
RukhankaMeshDeformation
amplify shader function to the created shader by dragging and dropping it from the project inspector. -
Connect the vertex position, normal, and tangent output ports of the
Rukhanka Mesh Deformation
node to the corresponding input ports of the master node. -
Set vertex position mode of the master node to
Absolute
. -
Save and assign this newly created shader to the materials of skinned mesh renderers.
Better Shaders
The Better Shaders
is a source-based shader generation tool. Rukhanka provides the shader snippets that can be included in your BetterShaders
shader.
Navigate to the Rukhanka installation directory and copy Rukhanka.Editor/BetterShaders/StackableRukhankaDeformation.surfshader
and Rukhanka.Editor/BetterShaders/StackableRukhankaDeformationMotionVectors.surfshader
files to the directory with your BetterShaders
shader. Use StackableRukhankaDeformation.surfshader
or StackableRukhankaDeformationMotionVectors.surfshader
(depending on motion vector requirements) in the first line of BEGIN_SUBSHADERS/END_SUBSHADERS
block. An example of a lit shader can be as follows:
BEGIN_OPTIONS
Stackable "False"
ShaderName "BetterShaders/LitAnimated"
END_OPTIONS
BEGIN_SUBSHADERS
// Must be first line in subshader list
"StackableRukhankaDeformation.surfshader"
// Use this line instead if ENABLE_DOTS_DEFORMATION_MOTION_VECTORS script symbol is defined
//"StackableRukhankaDeformationMotionVectors.surfshader"
"Lit.surfshader"
END_SUBSHADERS
Third-Party Shaders
Rukhanka Technologies can help you adapt custom shaders to work with Rukhanka Animation. Please contact us by support email or the official Discord
server.