• Editor
  • Is There A Way to Hint Z Position/Index to the RunTime?

I'm aware that for a single skeleton, I can re-arrange the draw-order of attachments in the editor. This question is more aimed at multi-skeleton animations. I've heard that some run-times (ones that are actually 3D) support setting the z position of pieces of an animation at run time. This would be like setting the draw order in the editor except it would (presumably) have a global effect. So two separate skeletons could interleave their draw orders.

So the question is: Is there a way for the editor to hint this z-position/index to the runtimes? I'm imagining this would be in the "Draw Order" part of the UI, but I haven't found anything that looks like it would handle this.

Related Discussions
...

The draw order index of an attachment is essential a z-position, and it's what the runtimes that render in 3D use to offset attachments while rendering. Depending on your runtime, you should be able to interleave skeletons to some degree. What runtime are you using?

Aaron B a écrit

So two separate skeletons could interleave their draw orders.

A side note from the runtime side:
While there is support to specify the distance (Z-Spacing) between attachments in some runtimes, it will not generally allow you to interleave two skeletons: When alpha blending is enabled (as is the default, for nice semi-transparent anti-aliased borders), ZWrite (depth write) will be turned off at the same time. Now when a skeleton is e.g. drawn in a single drawcall, any spacing between parts will not lead to any difference in relation on a second skeleton. This would only work when ZWrite is enabled (at the expese of non-alpha blended jaggy borders), leading to sorting via the depth buffer.

Mario a écrit

What runtime are you using?

I'm targeting TypeScript + WebGL.

Harald a écrit

... This would only work when ZWrite is enabled (at the expese of non-alpha blended jaggy borders), leading to sorting via the depth buffer.

Good to know. WebGL being what it is, I'm sure I could double the draw buffer size and then do some down-sampling if I needed some antialiasing effects. Although I'm not seeing a "ZWrite" when I grep through the spine-webgl.d.ts. Does this have an alternate name for the JS/TS builds?

In OpenGL this would be performed by setting glDepthMask(false) to disable writes and glDepthMask(true) to enable them.

In spine-ts I found this line here, however I'm not really familiar with the spine-ts runtime. Mario will be the one to trust in this regard.

For spine-ts, we have a test that shows the slot range feature of SkeletonRenderer:
spine-runtimes/test-slot-range.html at 3.8

Essentially, you tell the renderer to render up to a specific slot. Next you render whatever you want to interleave. Then you finish rendering the skeleton.

Arbitrary interleaving of attachments of two or more skeletons could be achieved like this as well, but it can hit your performance quite a bit if they don't share the same texture atlas.

Alright, thanks! That shows me how this could be done. Creating some specially named slots and moving them around the draw order should do the trick.

Though, just to make sure we're on the same page: The editor doesn't have a way to setup this sort of interleaving automatically by hinting depth values to the runtime?

No, I'm afraid the editor doesn't have that functionality. However, each slot has an index, which you could use as an offset for your interleaving scheme at runtime. The index of a slot is its index in the draw order, which is modifiable in the editor.

Ok, thanks!