Avatar T-Shirt Color With Print

Hi i’m working in a T-shirt with a print, and I need that the main color don’t affect the the print Like This without multiplying or change the color of the print. How do I can make change the color of the shirt without affect the print.

I’m using a png(Alpha) only with the print, but when i add to a shader it changes the color.

You need to write a custom shader for this that would use a mask like the texture’s alpha channel, to decide which parts of the model to tint. For example when the alpha is 1 you will use the texture color multiplied with the tint and when the alpha is 0 you will only use the texture color without multiplying it with a tint.

Let me know if you need more info on this.

I DID IT :smiley:


using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	
	public float r=0,g=0,b=0;
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		GameObject.Find("polySurface1").renderer.material.SetColor("_Color",new Color(r,g,b,1));
	}
}

Shader "ShaderAvatar/TShirt" {
    Properties {
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _BlendTex ("Alpha Blended (RGBA) ", 2D) = "white" {}
        _Color ("Main Color", Color) = (1,1,1,1)
    }
    SubShader {
    

    	
        Pass {
            // Apply base texture
            SetTexture [_MainTex] { 
                constantColor[_Color]
                combine constant lerp(texture) previous
            }
            // Blend in the alpha texture using the lerp operator
            SetTexture [_BlendTex] {
                combine texture lerp (texture) previous
            }
        }
    }
}

To make more clear what I was telling you in my first response, what I meant was that you can use only 1 texture for the whole thing.

The RGB of the texture will contain the print for your t-shirt. Now in the alpha channel of that texture you can set a pixel to 1 when you want it to be modified with a Color or set it to 0 when you do not want it to be modified ( so your print will be copied to the alpha channel of the texture as a black area ).

In your shader code you would do something like this:

half4 texColor = tex2D( _MainTex, IN.uv );
o.Albedo = lerp( 1, _Color, texColor.a ) * texColor.rgb;

That way you save memory and it will probably be more efficient as you do not have two texture accesses but only one.