Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Custom/Overlay"
- {
- Properties
- {
- _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
- }
- SubShader
- {
- Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
- ZWrite Off Lighting Off Cull Off Fog { Mode Off } Blend DstColor SrcColor
- LOD 110
- Pass
- {
- CGPROGRAM
- #pragma vertex vert_vct
- #pragma fragment frag_mult
- #pragma fragmentoption ARB_precision_hint_fastest
- #include "UnityCG.cginc"
- static const float4 _StartColor = float4(0.5f,0.5f,0.5f,0.5f);
- sampler2D _MainTex;
- struct vin_vct
- {
- float4 vertex : POSITION;
- float4 color : COLOR;
- float2 texcoord : TEXCOORD0;
- };
- struct v2f_vct
- {
- float4 vertex : POSITION;
- fixed4 color : COLOR;
- half2 texcoord : TEXCOORD0;
- };
- v2f_vct vert_vct(vin_vct v)
- {
- v2f_vct o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.color = v.color;
- o.texcoord = v.texcoord;
- return o;
- }
- float3 overlay_value(float3 b, float3 o)
- {
- float3 over;
- float f = 1.0-(1.0-b)*(1.0-o);
- float g = b * o;
- if(b.r<0.5)
- over.r = g;
- else
- over.r = f;
- if(b.g<0.5)
- over.g = g;
- else
- over.g = f;
- if(b.b<0.5)
- over.b = g;
- else
- over.b = f;
- return over;
- }
- float4 frag_mult(v2f_vct i) : COLOR
- {
- float4 tex = tex2D(_MainTex, i.texcoord);
- float4 final;
- final.rgb = overlay_value(tex.rgb,i.color.rgb);
- final.a = i.color.a * tex.a;
- return lerp(_StartColor, final, final.a);
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement