Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

How to apply a shader to a whole animation rig, instead of the individual parts?

Discussion in '2D Experimental Preview' started by ibbitzzz, Jan 30, 2021.

  1. ibbitzzz

    ibbitzzz

    Joined:
    Jun 15, 2018
    Posts:
    9
    Pretty much what the title says.

    I'm working on putting together my animation rigs using the 2D Animation package, and I'd like to apply an outline around the whole thing, but I can't seem to wrap my head around how to do it. My only guess would be to render all rigs that need to be outlined onto a texture using a camera then shading that, but that seems a little hacky, I just can't see how I could make a shader "aware" of other parts of the rig overlapping with it.

    Are there any better/more efficient ways of treating an animation rig as one object? For example, is it possible using Unity to create a frame buffer object or something that can be rendered to?
     
    Last edited: Jan 30, 2021
  2. MrPaparoz

    MrPaparoz

    Joined:
    Apr 14, 2018
    Posts:
    157
    I'm fiddling with same thing. I kind of have a solution. It's raw and needs some streamlining but here it goes. I'm guessing you already have a Outline Shader.

    For every part that's going to be outlined in object, duplicate child objects that has SpriteRenderer and SpriteSkin component. Change those objects' Renderer Order layer to -100 (or to an order number that make sure it's behind).
    Now when you apply your outline material to these duplicate renderers, overlapping sprites' outlines will be under main renderers.

    Because SpriteSkin component feeds deformed sprite mesh to SpriteRenderer I guess won't be any major issue with this approach.
     
  3. etkzz

    etkzz

    Joined:
    May 20, 2023
    Posts:
    5