• RuntimesUnity
  • How to make an outer outline when using SkeletonRenderSeparator?

Hello!

Basically we want only the outside of the object to have an outline. And the default outline option for spine material works perfectly (Spine/Outline/Skeleton shader). However, when using SkeletonRenderSeparator component, each separated slot is outlined individually, creating unwanted lines.

We have tried to limit mesh bounds to leave no space for the outline, yet it seems that a line of a few pixels is always drawn regardless.

Is there any solution or a workaround for this issue?

Cheers,
Tautvydas

Related Discussions
...

@Tautvydas Sorry to hear you're having troubles. Unfortunately the situation is not as easy with multiple separate meshes, be it due to multiple atlas pages requiring multiple materials, or when splitting the skeleton mesh via a SkeletonRenderSeparator component.

You can find some potential solutions in this forum posting:
https://esotericsoftware.com/forum/d/24307-multiple-materials-outline/5
Note that option (a) in the above posting does not apply obviously.

Your workaround using contracted mesh boundaries looks promising! Since it looks like a single pixel outline in your above image: if the border is exactly at the opaque vs. transparent pixel border, you might get an outline due to texture filtering / interpolation. Does the thin outline still occur when you contract the mesh outline by a larger distance?

4 дня спустя

Thank you for the reply and for directing to some workarounds!

The third option would be ideal for our use case, however, RenderExistingMesh "ignores" skeleton animations when SkeletonRenderSeparator is enabled (it simply renders the initial pose). Is there any way to modify RenderExistingMesh in order to work with SkeletonRenderSeparator?

Also, did some testing regarding this:

Does the thin outline still occur when you contract the mesh outline by a larger distance?

And it seems that some borders indeed have no outline, yet others still a single pixel outline:

Thanks,
Tautvydas

  • Harald ответили на это сообщение.

    One idea is to render the skeleton without a separator, solely to allow you to render an outline of the whole skeleton. Then render with the separator and slap the outline (without the skeleton) on top of everything. It's pretty common for an outline to be on top of everything, depending on your needs.

    @Tautvydas We have just added a new sample component RenderCombinedMesh. With this component you can combine the parts renderer meshes to a single one easily and assign an outline-only material to it.

    From the changelog:

    Added example component `RenderCombinedMesh` to render a combined mesh of multiple meshes or submeshes. This is required by `OutlineOnly` shaders to render a combined outline when using `SkeletonRenderSeparator` or multiple atlas pages which would normally lead to outlines around individual parts. To add a combined outline to your SkeletenRenderer:
     1) Add a child GameObject and move it a bit back (e.g. position Z = 0.01).
     2) Add a `RenderCombinedMesh` component, provided in the `Spine Examples/Scripts/Sample Components` directory.
     3) Copy the original material, add *_Outline* to its name and set the shader to your outline-only shader like `Universal Render Pipeline/Spine/Outline/Skeleton-OutlineOnly` or `Spine/Outline/OutlineOnly-ZWrite`.
     4) Assign this *_Outline* material at the new child GameObject's `MeshRenderer` component.
    If you are using `SkeletonRenderSeparator` and need to enable and disable the `SkeletonRenderSeparator` component at runtime, you can increase the `RenderCombinedMesh` `Reference Renderers` array by one and assign the `SkeletonRenderer` itself at the last entry after the parts renderers. Disabled `MeshRenderer` components will be skipped when combining the final mesh, so the combined mesh is automatically filled from the desired active renderers.

    A new spine-unity 4.1 unitypackage is available for download:
    https://esotericsoftware.com/spine-unity-download

    Please let us know if this resolves your issue.

    Tautvydas Also, did some testing regarding this:
    Does the thin outline still occur when you contract the mesh outline by a larger distance?

    And it seems that some borders indeed have no outline, yet others still a single pixel outline:

    This is strange. Unfortunately I could not reproduce this issue on my end with contracted mesh bounds. I've checked the shader, however it should not introduce any offset in XY direction. Could you perhaps send us a minimal Unity project which still shows this behaviour? You can send it as a zip package to contact@esotericsoftware.com, briefly mentioning this forum thread URL so that we know the context. Then we can have a look at it.

    Thanks for the follow-up!

    RenderCombinedMesh looks very promising, but I've had some issues with setting it up. It seemed to generate artifacts and mesh distortions:

    Have I missed any steps?

    @Tautvydas Thanks for reporting and sorry for the troubles! This was indeed a bug, we've pushed a bugfix commit (fixing two issues actually), new spine-unity 4.1 and 4.2-beta unitypackages are available for download:
    https://esotericsoftware.com/spine-unity-download
    Please let us know if this resolves your issue on your end as well.

    It works perfectly now, thank you very much!

    11 дней спустя

    Regarding your second reproduction project:

    Tautvydas And it seems that some borders indeed have no outline, yet others still a single pixel outline:

    The issue originates from atlas packing. When the mesh polygon is "cutting" into opaque attachment sections and Pack Settings Packing is set to Polygons, the resulting attachment image part is too aggressively cut off to a transparent color at the middle of the texel (instead of outside). This ultimately leads to aliasing artifacts and letting the outline from behind show through at any of the "staircase" texels.

    A quick solution for now would be to use Packing mode Rectangles. I will forward this topic to Nate. Thanks for reporting!

    @Tautvydas Nate has just implemented an improved version of polygon packing which includes border texels at full opacity. It will be included in the next 4.2-beta release of the Spine Editor. Thanks again for reporting!

    7 дней спустя

    Awesome, thanks for the update!