Secondary color shader


We wanted to have some color variation in our packlings to add some variety to enemies and maybe some customization for players, so I made a shader for that.



It takes in a secondary texture and uses it as a mask to decide where this secondary color will be applied, and does so while keeping the value of the main texture.

This is the subshader code to modify the albedo:

float4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
float mask = tex2D(_SecondaryColorMask, IN.uv_MainTex).a;
float value = (c.r + c.g + c.b) / 3;
c.rgb = c.rgb * (1-mask) + _SecondaryColor * mask * value;
o.Albedo = c.rgb;

This is the mask for this particular model, I just took the main texture and edited it in gimp to erase certain areas and decrease the opacity of other.

Get Pack

Leave a comment

Log in with itch.io to leave a comment.