Shader graph - applying sprite renderer color to mask
Hello, if someone could help me with it would be very much appreciated. I want to change the color of the iris from an eye sprite I have so I can make different characters with different eye colors (the sprite itself has green eyes). I've managed to do just that with shader graph, however when I change the eye color in the shader, every character with the same shader gets the same color. I've tried to apply the spriterenderer color in the graph with the "vertex color" node in the place where _IrisColor is, but when I change the sprite renderer color it is applied to all the sprite and not just where the vertex color node is in my shader. Is there a way to do this? Make the color from the sprite renderer affect only some parts of the sprite, like a mask?
Answer by mateusthiago · Nov 30, 2019 at 04:06 PM
Ok, I found out a way to get around this. This is a problem with Shader Graph, when I looked at the generated code (right clicking on the master node), I found this line at the frag function in the shader, which is the function that sets the color for the pixels:
surf.Color *= IN.VertexColor;
So no matter what you do inside shader graph, in the end the vertex color from the sprite renderer will always be multiplied over the final output.
Just delete or comment ou this line, save the generated code as a new shader and use it.