Created by
Omer F. Sayilir
| Shader "Unlit/LUT"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_RedOverlay ("RedOverlay", 2D) = "white" {}
_BlueOverlay ("BlueOverlay", 2D) = "white" {}
_GreenOverlay ("GreenOverlay", 2D) = "white" {}
_Greyscale ("GreyscaleOverlay", 2D) = "white" {}
_GreyscalePower ("Greyscale Power", Range (0, 1)) = 1
}
SubShader
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True"}
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
sampler2D _RedOverlay;
sampler2D _BlueOverlay;
sampler2D _GreenOverlay;
sampler2D _Greyscale;
float4 _MainTex_ST;
float4 _RedOverlay_ST;
float _GreyscalePower;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
fixed4 r = tex2D(_RedOverlay, i.uv*_RedOverlay_ST.xy);
fixed4 g = tex2D(_BlueOverlay, i.uv);
fixed4 b = tex2D(_GreenOverlay, i.uv);
fixed4 gr = tex2D(_Greyscale, i.uv);
fixed4 ret;
r.a = col.r;
r.rgb *= col.r;
g.a = col.g;
g.rgb *= col.g;
b.a = col.b;
b.rgb *= col.b;
float4 sum = (r+g+b);
sum.rgb = sum.rgb - float3(gr.a,gr.a,gr.a) * _GreyscalePower;
sum.a += gr.a;
return sum;
// apply fog
UNITY_APPLY_FOG(i.fogCoord, col);
}
ENDCG
}
}
}
|