Hey there,
Im trying to sample behind a quad and change any pixel that is white to a different color.
Right now its kind of working but it seems as if the IF statement in the frag function is always true.
Is there anything you guys think I am doing wrong or any way I can replace the white pixels.
Im pretty new to shaders and it doesnt seem like many people use shaders for text so its hard to get a good
answer from the internets.
Thanks in advance,
CG
Shader "Custom/Unlit/ColorChangeShader"{
Properties
{
_Color("Tint Color", Color) = (1,1,1,1)
_Color2("Tint 2 Color", Color) = (0,0,0,0)
}
SubShader
{
Tags{ "Queue" = "Transparent" }
Pass
{
ZWrite On
ColorMask 0
}
//Blend OneMinusDstColor OneMinusSrcAlpha //invert blending, so long as FG color is 1,1,1,
//Blend OneMinusDstColor OneMinusSrcAlpha
BlendOp Max
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
uniform float4 _Color;
uniform float4 _Color2;
struct vertexInput
{
float4 vertex: POSITION;
float4 color : COLOR;
};
struct fragmentInput
{
float4 pos : SV_POSITION;
float4 color : COLOR0;
};
fragmentInput vert(vertexInput i)
{
fragmentInput o;
o.pos = mul(UNITY_MATRIX_MVP, i.vertex);
o.color = i.color;
//o.color = _Color2;
return o;
}
half4 frag(fragmentInput i) : COLOR
{
if (any(i.color == _Color))
{
i.color = _Color2;
}
return i.color;
}
ENDCG
}
}
}