Advertisement
Guest User

Untitled

a guest
Aug 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/Overlay"
  2.  {
  3.      Properties
  4.      {
  5.          _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
  6.      }    
  7.      SubShader
  8.      {
  9.          Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
  10.          ZWrite Off Lighting Off Cull Off Fog { Mode Off } Blend DstColor SrcColor
  11.          LOD 110
  12.          Pass
  13.          {
  14.              CGPROGRAM
  15.              #pragma vertex vert_vct
  16.              #pragma fragment frag_mult
  17.              #pragma fragmentoption ARB_precision_hint_fastest
  18.              #include "UnityCG.cginc"
  19.              static const float4 _StartColor = float4(0.5f,0.5f,0.5f,0.5f);
  20.              sampler2D _MainTex;
  21.              struct vin_vct
  22.              {
  23.                  float4 vertex : POSITION;
  24.                  float4 color : COLOR;
  25.                  float2 texcoord : TEXCOORD0;
  26.              };
  27.              struct v2f_vct
  28.              {
  29.                  float4 vertex : POSITION;
  30.                  fixed4 color : COLOR;
  31.                  half2 texcoord : TEXCOORD0;
  32.              };
  33.  
  34.              v2f_vct vert_vct(vin_vct v)
  35.              {
  36.                  v2f_vct o;
  37.                  o.vertex = UnityObjectToClipPos(v.vertex);
  38.                  o.color = v.color;
  39.                  o.texcoord = v.texcoord;
  40.                  return o;
  41.              }
  42.              float3 overlay_value(float3 b, float3 o)
  43.              {
  44.                 float3 over;
  45.                 float f = 1.0-(1.0-b)*(1.0-o);
  46.                 float g =  b * o;
  47.                 if(b.r<0.5)
  48.                     over.r = g;
  49.                 else
  50.                     over.r = f;
  51.                 if(b.g<0.5)
  52.                     over.g = g;
  53.                 else
  54.                     over.g = f;
  55.                 if(b.b<0.5)
  56.                     over.b = g;
  57.                 else
  58.                     over.b = f;
  59.                 return over;
  60.              }
  61.              float4 frag_mult(v2f_vct i) : COLOR
  62.              {
  63.                  float4 tex = tex2D(_MainTex, i.texcoord);
  64.                  float4 final;
  65.                  final.rgb = overlay_value(tex.rgb,i.color.rgb);
  66.                  final.a = i.color.a * tex.a;
  67.                  return lerp(_StartColor, final, final.a);
  68.              }
  69.              ENDCG
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement