Blend 2 SkinnedMesh Vertices positions/normals in 3rd SkinnedMesh's Custom Vertex shader Based on Builtin Standard shader

Hi,

I have to blend vertices positions from 2 meshes with vertex colors as factor.

its the same skinned mesh used for physics sim (custom physics engine transfers deformations to bones, cant do nothing about that), skeletal anim, and the final one has to be a blend of the two previous using vertex colors as lerp factor. black/white red channel is used.

tried 3 different ways.

  • compute shaders, no idea how to apply the deformations done in the compute shader to the graphicsbuffer on third mesh.
  • same as prev applying to vertices is slow as hell.
  • vertex shader, works fine except i know nothing about standard shader pipeline, and a dozen passes are missing, object looks like it was software rasterized 25 years ago.

If anybody has a solution to this.

Basically i use graphicsbuffer in the vertex shader to lerp values and apply to current mesh’s vertex.

Source files are attached to this post.

SkinnedMeshBuffer.cs (2.8 KB)
SkinnedMeshBuffer.shader (6.4 KB)

If you can just take a quick look, and give me a direction. My fear is to go through the entire standard shader and add my vertex blending code to every single pass, thats what i am trying to dodge.

How you can test this

  • spawn 3 skinnedmesh renderers
  • rotate a bone on the first object’s skeleton, cause if there is no diff between the two first objects, how would you know it works?!!
  • on the last obj attach the cs file, set the material to use the provided shader.

in the editor viewport, the mesh will vanish from existence, cause we feed buffer values during play update.