• RuntimesUnity
  • workflow for Shader Graph Question

Our project aims to implement universal effects like dissolve and clipping through Shader Graph, affecting all objects. Currently, I am considering:

  • Changing the default material imported with Spine into Unity to a custom Shader Graph material.
  • The custom Shader Graph will include all necessary effects for the project, adjustable via parameters.

My questions are:

  • Is this workflow practical?
  • Do Skeleton PMA Screen and Skeleton PMA Multiply also need to be switched to custom materials? How would this be done?

I'm looking forward to feedback, thank you.!

    Related Discussions
    ...

    Your workflow of changing the default material imported with Spine into Unity to a custom Shader Graph material is practical and a common approach for applying universal effects like dissolve and clipping. The Spine-Unity runtime documentation provides guidance on using custom materials and shaders with Spine skeletons, including the use of Shader Graph. You can find relevant information in the Shader Graph and Materials sections.

    For your specific questions:

    • Yes, the workflow is practical. You can replace the default materials with custom Shader Graph materials to apply universal effects. Ensure your Shader Graph materials are set up correctly to handle Spine's specific requirements, such as Premultiplied Alpha (PMA) if your project uses it.
    • Regarding Skeleton PMA Screen and Skeleton PMA Multiply, if your project uses these blend modes and you want the effects to apply to them as well, you will need to create custom materials for these blend modes too. This involves creating Shader Graph shaders that replicate the blend modes' behavior and assigning them to the respective materials. The process of switching to custom materials involves replacing the default materials in the Spine skeleton's material slots with your custom materials. This can be done programmatically or by manually setting the materials in the Unity Editor, depending on your project's setup and needs.

    Remember, when working with custom shaders or materials, it's crucial to understand how Spine's rendering works, especially regarding PMA and blend modes, to ensure compatibility and the desired visual outcome.

    @sayi Spinebot is basically correct.

    Since you mentioned dissolve: note that unless you intend to do a binary dither dissolve, you will run into issues with overlapping semi-transparent attachments as explained here:
    https://esotericsoftware.com/spine-unity#Fading-a-Skeleton-In-or-Out
    Also check out the Spine Examples/Other Examples/RenderTexture FadeOut Transparency example scene.

    sayi Do Skeleton PMA Screen and Skeleton PMA Multiply also need to be switched to custom materials? How would this be done?

    If you really want to switch these shaders to Shader Graph, the output blend mode needs to be adjusted accordingly at the output of your generic shader graph. For:

    • Skeleton PMA Screen it's Blend One OneMinusSrcColor
    • Skeleton PMA Multiply it's Blend DstColor OneMinusSrcAlpha
      Admittedly I don't recall whether these output blend modes can be configured freely with Shader Graph, you would need to check that out.

    Do Skeleton PMA Screen and Skeleton PMA Multiply also need to be switched to custom materials?

    No, I see no reason why you would want to also include blend mode shaders into a single Shader Graph, which does not really gain you anything. You need to answer the question yourself however why you are switching to Shader Graph in the first place, what benefits you are expecting from that.

    Shader Graph basically just generates loads of shader variants anyway depending on all parameter options that you provide. In the end, there is not much of a difference between a normal shader with a given parameter option set and a Shader Graph shader with a similar parameter option set.

    Whether you're using 3 separate shaders or 3 shader variants of a single generic shader (with different parameter options enabled) makes no real difference.