Search Unity

Question Colour Replacer

Discussion in 'Shader Graph' started by piggybank1974, Dec 3, 2020.

  1. piggybank1974

    piggybank1974

    Joined:
    Dec 15, 2015
    Posts:
    621
    This is the first time I've tackled using Shader Graph, so you will have to bear with me on this.

    I've created a Test Circle Image with colours, so what I'm wanting to do is replace a colour with another colour, sounds basic, it sort of works but I'm not sure of a couple of things and why:

    1 - Why is the new Shader/Material in the Shader Graphed Image not looking "Circle" like the Sprite Image on the right.

    2 - If a want to change the pink colour, for example, I have to add a little value to the Range e.g 0.01 so it will change it, but if it's a pure colour e.g the red or green I don't have to.

    This might not be the correct way to do it but I'm trying to figure out a way to give my character different colours.

    Cheers
     

    Attached Files:

  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,511
    This is likely b/c you're not passing the alpha from the texture through to the alpha of the output master node.

    This is speculation but it may be that the Color input is a float4 whereas your texture may use what is more equivalent to Color32, which has byte resolution. So that could be a float-byte where the colors are in fact a tiny bit different.
     
  3. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Since you said you want to give your characters different colors, I think you might be better off if you used grayscale for indexing your colors you want to replace. It might be easier to work with. You could just use grayscale values on your character as the index, and then use those to fetch values from a gradient, for example. Or use some other setup to pick colors from predefined set of color variables.

    Or do you actually want to make an color replacement shader?
     
  4. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    i.e. something like this, just in case my explanation wasn't clear enough. Very simple and might work for some cases:

    20201206_colorize.PNG
     
    florianhanke likes this.