Hi!
We are having a problem with one of our characters inside Unity,
Our character has loads of customizations and Spine generates multiple texture atlas to accommodate all the assets. The issue comes when we use the outline shader, it renders weird. Things that are on the second Sprite sheet get an outline on all of their edges, and the figure looks strange with outlines going through the middle of the figure, when what we wanted was only one outline going around the character.
How can we solve it?

    Related Discussions
    ...

    Nevitiv

    The issue comes when we use the outline shader, it renders weird. Things that are on the second Sprite sheet get an outline on all of their edges, and the figure looks strange with outlines going through the middle of the figure, when what we wanted was only one outline going around the character.

    It is correct behavior that outlines to be drawn on all edges of image attachments. By rendering the mesh of the skeleton in front of the outlines, the result is to make it appear that the outlines are only around the character.

    How can we solve it?

    Does your Unity project use URP shaders? URP does not allow multiple passes per shader, so it requires a separate material. You might want to consider the RenderExistingMesh component, as demonstrated in the com.esotericsoftware.spine.URP-shaders/Examples/Outline Shaders URP example scene included in the URP Shaders UPM package.

    By the way, you can repack the texture atlas pages to combine used texture regions of a collected skin to a single texture at runtime. For more information, please refer to the "Runtime Repacking" section of the documentation:
    http://esotericsoftware.com/spine-unity#Combining-Skins

    Nevitiv If you have multiple atlas pages and thus multiple Materials in use, you also need to replace both materials accordingly with the respective outline shader material (and the original texture). In general please always share as much information as possible in advance about your setup, like whether you are using URP or the standard render pipeline, some screenshots showing your skeleton setup, how you replaced the material with the outline material, etc.

    9 days later

    Of course!
    About the project:


    Unity 2019.4.9 we plan to upgrade it to 2020 or 2021.
    Project is using Built-in Render Pipeline
    Spine version: 3.8.xx

    And to clarify, all our characters have the outline material for the aesthetic of the game. And it looks like a clustered outline "behind" the character.

    The MC has loads of customization options so when we had to create multiple texture atlas to accommodate them we started noticing the outline was set one per material instead of a cluster one and sometimes the arm that goes behind the body renders in front of it.

    @Nevitiv Thanks for the additional info. I just checked the behaviour of the outline shaders with multiple atlas pages. I just noticed I forgot that it is mandatory that all materials are using shaders with ZWrite enabled. Otherwise the second draw call using the second material will draw the undesired inner outline on top of the already rendered parts of the previous draw call of the same character.

    So you basically have some options to:

    • a) Repack the skin (or pack your atlas so that it uses only one atlas page texture) to use a single atlas texture, then the outline is rendered behind the whole skeleton.
    • b) Use a provided Spine shader that has ZWrite enabled (also called "Write to depth" or "Depth write") or create a modified version of a provided outline shader where ZWrite is enabled at the normal pass.
    • c) Render the skeleton normally using a non-outline material, and use the RenderExistingMesh component to render the outline-only-skeleton behind the skeleton with a material using the shader Spine/Outline/OutlineOnly-ZWrite.