Search Unity

Sprite renderer to update secondary texture channel (emission)

Discussion in 'General Graphics' started by grossimatte, Oct 1, 2019.

  1. grossimatte

    grossimatte

    Joined:
    Mar 15, 2013
    Posts:
    43
    Hello,
    How can i inject a texture to a shader's _Emission map slot, depending on the currently played sprite animation clip in mecanim?

    E.G.
    I have a material that accept a _MainTex and _Emission

    upload_2019-10-1_8-28-18.png

    The sprite renderer automatically swap the sprite sheet in the _MainTex slot once a given animation is being played in mecanim.

    I want the sprite renderer (or a custom solution) to also inject the corresponding _Emission to the correct slot.

    I was thinking of "listening" to the state change in mecanim, get the clip name and then look for a "currentlyplayedclipname" + "_emissive" .png, and finally apply it to the _Emission slot.

    Would this work? Any other ideas?

    Thanks!
     
    Last edited: Oct 1, 2019