Hey guys, can you help me translate the following instructions into shader code? I know how to do this with a node editor like amplify, but I don’t know how to write it in code. So here is the instruction:
“You need to open the diffuse atlas shader. add your color property in the top and as a variable
then multiply the result color with that in the pixel shader function”
And here is the shader:
sampler2D _MainTex;
float _Cutoff;
float4 _Color;
float _IsBark;
float _Culling;
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float3 n : TEXCOORD1;
float4 color : COLOR0;
};
v2f vert(appdata_full v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord.xy;
o.n = mul(UNITY_MATRIX_V,float4(v.normal.xyz,0)).xyz;
o.color = v.color;
return o;
}
half4 frag(v2f i, float face : VFACE) : SV_Target
{
half4 c = tex2D (_MainTex, i.uv);
// detect bark
if (_IsBark == 1) {
c.a = 1;
}
else {
clip(c.a - _Cutoff);
}
c.rgb = lerp(c.rgb, (c.rgb + _Color.rgb) * 0.5, i.color.r * _Color.a);
c.rgb = clamp(c.rgb, 0, 1);
return c;
}
ENDCG
and a question. My color property… does that need to a reference to a material?
what i am doing is turnign a shader that creates billboards from the texture values of a material, and making it so that it also reads the tint value of the material as well.