Bone Attachemnts
- CPU Animator
- GPU Animator
CPU Animator writes animated bone positions back to the LocalTransform components of corresponding bone entities. No special preparation step is needed to work on bone attachments properly. Just make the attachment entity a child of required bone entity.
Bone entities cannot be moved by the GPU animation engine. The simple attachment process used in the CPU Animator would not work. Because bone calculation is performed on GPU, all frame bone placement data is stored in GPU memory and cannot be copied to the main memory to be used by entities at the same frame. Nevertheless, a special shader can be created, which will move all model vertex positions according to the animation frame.
Bone attachment shader using ShaderGraph
The process is similar to the making of a deformation-aware shader for an ECS skinned mesh renderer.
- Create a new shader graph according to the render pipeline used in your project.
- Open it and add the
Custom Functionnode. - Set
TypetoFile. - Set
NametoGPUAttachmentMeshMover. - Set
SourcetoGPUAttachmentShaderNode.hlsl(located atRukhanka.Runtime/GPUAnimationEngine/Resources/GPUAttachmentdirectory). - Configure three input ports of this custom node:
vertexwith typeVector 3.normalwith typeVector 3.tangentwith typeVector 3.
- Configure three output ports:
animatedVertexwith typeVector 3.animatedNormalwith typeVector 3.animatedTangentwith typeVector 3.
- Create three additional nodes in the shader graph:
Geometry PositionwithSpaceproperty set toObject.Geometry Normal VectorwithSpaceproperty set toObject.Geometry Tangent VectorwithSpaceproperty set toObject.

- Connect the
Outport of thePositionnode with thevertexport of theGPUAttachmentMeshMover (Custom Function)node. - Connect the
Outport of theNormal Vectornode with thenormalport of theGPUAttachmentMeshMover (Custom Function)node. - Connect the
Outport of theTangent Vectornode with thetangentport of theGPUAttachmentMeshMover (Custom Function)node. - Connect the
animatedPosition,animatedNormal, andanimatedTangentoutput ports of theGPUAttachmentMeshMover (Custom Function)node to the vertex position, normal, and tangent ports in the master node respectively.
You should get the following shader graph:

- Complete fragment part of the shader graph with appropriate texture sampling (albedo, normal map), color modulation, etc.
Use the created shader as a material shader of your GPU-attached meshes.
Marking mesh as GPU attachment
Rukhanka must supply a GPU attachment shader with appropriate rig data. To be able to do this, you must add GPU Attachment Authoring Unity component to every authoring mesh in authoring GameObject:

Object with GPU bone attachment shader but without GPU Attachment Authoring will be rendered incorrectly, or will completely disappear from the scene.
GPU attachments will work normally as ordinary CPU attachments