• Unity
  • How to add additional uv's to SkeletonGraphic

I am trying to apply a custom shader to my skeletons that will help me reduce the draw calls for mobile. I need to add some uv1 information to the vertices of the SkeletonGraphic but I cannot seem to find a way to change it. Is there a proper solution to this?
Note: I cannot use separate material instances, otherwise they will be on separate draw calls. It has to be per-vertex

Related Discussions
...

You could use the MeshGeneratorDelegate OnPostProcessVertices to hook up your own code after the mesh buffers have been filled by the MeshGenerator, before the data is assigned at the Mesh:

Note that you will need to enable meshGenerator.settings.tintBlack or adjust the MeshGenerator code accordingly so that the additional uv2 and uv3 vertex data is actually written to the Mesh in meshGenerator.FillVertexData(mesh) at this line.

You can check out the example script JitterEffectExample in the example scene Spine Examples/Other Examples/VertexEffect which shows an example on how to basically use the OnPostProcessVertices callback delegate.

12 days later

Sorry for the late reply. Regarding the OnPostProcessVertices, I can only access the uvBuffer, colorBuffer, and vertexBuffer. The JitterEffectExample modifies the vertexBuffer to do the effect. I would like access to uv2/uv3 buffer. Is there a way around this?


Update: Since I just needed to store a boolean and I am using a Skeleton Graphic, I decided to set the vertex z value to 0/1 (off or on)

Sorry for the inconvenience, glad that you have found a workaround. You are right that the provided MeshGeneratorBuffers struct does not yet allow access to the uv2 and uv3 data. We will add respective fields on the 4.2-beta branch accordingly.


Accessors for uv2Buffer and uv3Buffer properties have just been implemented on the 4.2-beta branch. Thanks again for reporting!

From the changelog:

changelog.md wrote
  • OnPostProcessVertices callback parameter MeshGeneratorBuffers now provides access to uv2Buffer and uv3Buffer properties of MeshGenerator, automatically allocating buffers upon access if tintBlack is disabled. This allows for passing own vertex data to a shader on second and third uv channels.

A new 4.2-beta spine-unity unitypackage is available for download here as usual:
spine-unity Download

For later reference: this issue has been tracked under this issue ticket:
https://github.com/EsotericSoftware/spine-runtimes/issues/2230