Dots Animation Skinning

Hi, I have been looking around but cannot work out how to transform my bone skinning code into GPU code with the new DOTS hybrid rendering v2.

Currently my system on the CPU will do a simple calculation to transform each mesh vertex:

var position = vert.position;
var currentMatrix = skeletonAnimationLink.boneMatrixes[boneIndex];
var originalMatrix = skeletonAnimationLink.originalMatrixes[boneIndex];
position = math.transform(math.mul(currentMatrix, math.inverse(originalMatrix)), position);
vert.position = position;
chunkMeshAnimation.vertices *= vert;```*
*It will take the current bone matrix, the original, and simply transform the position by the difference.*
*I tried to convert this code into a shader at first, but had significant problems getting a written shader to work in the new systems. So my next attempted solution was a shadergraph. I recall we used to be able to write a custom shader graph node, I might possibly need to do that again (if anyone has a suggestion).*
*![](https://i.ibb.co/VM5VD8B/awdafwe.png)*
*My latest try was to set it up so the matrix, or a series of them per bone, (original and latest) are set as variables that I can then update with my CPU systems. This would still be a significant speedup as it would move the vertex processing to the GPU. However the shader graph nodes didn't have any inputs for Vertex Position, so this stopped my progress.*
*Does anyone have any ideas at how to solve this (the most performant way)? I am fine with writing a shader or a shadergraph, I just need to be able to send the bone data into the GPU and do the processing of vertexes there.*
*Edit: Something like this might be possible I mean as a shadergraph. It just does not seem like a good solution. I'm not sure how to pass in the Bone Index, and then chose a property based on it.*
*![](https://i.ibb.co/d4QTWLY/bone-Skinning-Shader.png)* 
*I think shadergraph is limited so it's probaly best to write a shader. But it seems very difficult to write shaders for shadergraph, possibly impossible? If there's any examples, please let me know.*
1 Like

Thanks! I ended up writing a custom shader instead and used compute buffers to set data in them.

I also use same way.

1 Like