- Home /
How to lighten/darken a greyscale shader
Hi I'm trying to figure out how to possibly add a slider in that can make each pixel value of a greyscale shader closer to white on one end of the slider, while the other end makes each pixel value closer to black. Here is the greyscale shader I am currently using, I'm just not quite sure where to start.
Shader "Unlit/GreyScale" {
Properties{
_MainTex("Texture", 2D) = "white" { }
}
SubShader{
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
float4 _MainTex_ST;
v2f vert(appdata_base v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
half4 frag(v2f i) : COLOR
{
half4 texcol = tex2D(_MainTex, i.uv);
texcol.rgb = dot(texcol.rgb, float3(0.3, 0.59, 0.11));
return texcol;
}
ENDCG
}
}
Fallback "VertexLit"
}
Comment