As can be seen from the picture above. I have made some beards and hair for my game that I want to allow the player to paint at will. However, the beard and hair, have some leather straps, that I don’t want being affected by the color.
I am wondering how I would go about this. I am assuming that it is not possible with the material that I am using so I therefore made a little bit of a dive into shadergraph for the first time. But I am kinda lost and could use some guidance.
In shadergraph I made something like this:
But this doesn’t quite solve the issue as I end up with the leather strap being ignored fine, but then the color is placed 100% everywhere instead of mixing the color with the basemap. I am now ready to ask for help on this. Am I doing something dumb here? is there a smarter way to achieve what I am going for?
if you lerp a color with only 0 and 1, it will only return either the first or second input, i think you would probably want to do some maths to make it so when the color is 0 it will return .5 or something like that. you could do this with max(.5, alphamap.r). this will make any color lower than .5 clamp there, and anything higher stay as it is.
I quickly sketched something that might help
The whole idea is removing the albedo texture pixels where the leather is going to be and them sum it with a modified version that has color. You also can control the leather strip color with that.
You could do that with fancy alpha channel logic but this looks easier. Also there are a lot of ways to do achieve that too and this is subject to optimization. Hope it helps
Thanks for the input both of you. I had actually solved this myself, but @murilomsq your solution is really elegant and so I decided to implement it, I extended it a little bit by making it so that I can choose the original color of the leather or alternately overlay some color on the leather piece. Let me know what you think (I mentioned you in the description of the video):
1 Like
Looked cool with the albedo texture blending! You can save some good GPU work if you store your “alpha map” texture inverted so you dont have to do it in the fragment shader.
I might note, though, that “alpha mapping” is not exactly what is being done here. We are using the RGB channels to store the leather and albedo texture data and operate with. The alpha channel is not being used, matter of fact, if you wanna optimize this to the fullest, you could switch from an RGB texture to an alpha texture and carry the operations using only the alpha channel; as you’re doing some blending it might need some thought but it is definetly an idea.
If you ever need to optimize this, these are valid things to try.
1 Like
@murilomsq I really appreciate your insights and assistance. I hope this discussion will be beneficial to others in the future. I’ve now implemented your suggestions and plan to update the YouTube video once we finalize our solution. I’m not aiming to become a YouTuber; my goal is simply to share reliable and useful information.
Here’s what I did: I modified the albedo texture in Photoshop by adding an extra channel for the alpha map. I saved this as a .targa file, ensuring that the ‘alpha channel’ option was checked during the save process.

In Unity, I updated the shader to utilize the alpha channel directly, eliminating the need for a separate texture. I also confirmed that we don’t need to invert the colors.
This approach has significantly reduced the complexity of our shader graph, using far fewer nodes. However, I’m curious if you see any further opportunities for optimization?