- Home /
Color tint on a shader.
I made the simple shader but I don't know how to get the colour tint to work properly?
Shader "Custom/IlumBlend" {
Properties {
_Color ("Color Tint", Color) = (1,1,1,1)
_MainTex ("Texture 1", 2D) = ""
_Texture2 ("Texture 2", 2D) = ""
}
SubShader {
Material {
Emission [_Color]
}
Pass {
SetTexture[_MainTex]
SetTexture[_Texture2] {
combine texture * primary + previous
}
}
}
}
Answer by Julien-Lynge · Jun 26, 2013 at 03:25 PM
Here's the reference you want:
http://docs.unity3d.com/Documentation/Components/SL-SetTexture.html
Take a look at the constantColor stuff.
Nah, I still don't get it. I tried modifying the Illume Diffuse shader and got this.
Shader "IllumBlend2" {
Properties {
_Color ("$$anonymous$$ain Color", Color) = (1,1,1,1)
_Tex1 ("Texture1 (RGB) Gloss (A)", 2D) = "white" {}
_Tex2 ("Texture2 (RGB) Gloss (A)", 2D) = "white" {}
_EmissionL$$anonymous$$ ("Emission (Lightmapper)", Float) = 0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRA$$anonymous$$
#pragma surface surf Lambert
sampler2D _Tex1;
sampler2D _Tex2;
fixed4 _Color;
struct Input {
float2 uv_Tex1;
float2 uv_Tex2;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_Tex1, IN.uv_Tex1);
fixed4 c = tex * _Color;
o.Albedo = c.rgb;
o.Emission = c.rgb + UNITY_SA$$anonymous$$PLE_1CHANNEL(_Tex2, IN.uv_Tex2);
}
ENDCG
}
FallBack "Self-Illu$$anonymous$$/VertexLit"
}
It very nearly works but I can't figure it out.
You don't seem to have ended up using the ShaderLab constantColor method as suggested and ins$$anonymous$$d have replaced your shader with a surface shader, which is much more complicated (not wrong, just more complicated). I suggest going back to the shader reference, and reading the various pages on ShaderLab, along with the examples.
Shader "Custom/IlumBlend" {
Properties {
_Color ("Color (RGB)", Color) = (1,1,1,1)
_Texture1 ("Texture1 (RGB) Texture (A)", 2D) = "white" {}
_Texture2 ("Texture2 (RGB) Texture (A)", 2D) = "white" {}
}
SubShader {
Pass {
Lighting Off
SetTexture [_Texture1] {
constantColor [_Color]
combine constant lerp(texture) previous
}
SetTexture [_Texture2]{
combine texture lerp (texture) previous
}
}
}
}
I went back the the first example but I still don't get it. Is there a command to combine them in the first set of {}? When I swap constant color into the second {} it breaks.