Search Unity

Resolved How to blink color in sprite using 'Replace Color' with Shader Graph

Discussion in 'Shader Graph' started by Jointy87, Aug 16, 2020.

  1. Jointy87

    Jointy87

    Joined:
    Dec 19, 2019
    Posts:
    21
    Hi all.

    I've started trying to figure out Shader Graph a bit with the goal of being able to have my sprite's weapon blink between a chosen color and it's default color. The weapon is not a seperate sprite but is part of the player sprite.

    I've checked out some tutorials online and managed to get pretty far. Through the shader I can now swap the weapon color using 'Replace Color' node. However, this now just means that the weapon's color is swapped always. I want to be able to control the color swap by turning the color replacement on and off by simply communicating with a Vector1 that sets the opacity of it or something. I've tried several ways to achieve this but I can't get it right at all.

    My current shadergraph looks like this:
    upload_2020-8-16_14-26-55.png

    I've tried setting step nodes and multyplier nodes into the 'to' field of the color replacer but I just can't get it right.

    Anybody got any idea's how I should set this up so I'm able to control when the color is replaced?

    Thanks so much! Cheers!
     

    Attached Files:

  2. Jointy87

    Jointy87

    Joined:
    Dec 19, 2019
    Posts:
    21
    Figured a way to do it using the Gradient node and connecting a vector1 to that. Now I can switch between flash color and original color. Not the way I intended it (flash between flash color and invisible) but this works fine for now.