Advertisement
Guest User

Untitled

a guest
Feb 1st, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.54 KB | None | 0 0
  1. Shader "Custom/Test"
  2. {
  3.     Properties
  4.     {
  5.         _MainTex ("Albedo Texture", 2D) = "white" {}
  6.         _TintColor("Tint Color", Color) = (1,1,1,1)
  7.         _Transparency("Transparency", Range(0.0,1)) = 1
  8.         _Height("Height", Range(0,100)) = 1
  9.     }
  10.  
  11.     SubShader
  12.     {
  13.         Tags {"Queue"="Transparent" "RenderType"="Transparent" }
  14.         LOD 100
  15.  
  16.         ZWrite Off
  17.         Blend SrcAlpha OneMinusSrcAlpha
  18.  
  19.         Pass
  20.         {
  21.             CGPROGRAM
  22.             #pragma vertex vert
  23.             #pragma fragment frag
  24.  
  25.             #include "UnityCG.cginc"
  26.  
  27.             struct appdata
  28.             {
  29.                 float4 vertex : POSITION;
  30.                 float2 uv : TEXCOORD0;
  31.             };
  32.  
  33.             struct v2f
  34.             {
  35.                 float2 uv : TEXCOORD0;
  36.                 float4 vertex : SV_POSITION;
  37.             };
  38.  
  39.             sampler2D _MainTex;
  40.             float4 _MainTex_ST;
  41.             float4 _TintColor;
  42.             float _Transparency;
  43.             float _Height;
  44.            
  45.             v2f vert (appdata v) {
  46.                 v2f o;
  47.                 o.vertex = UnityObjectToClipPos(v.vertex);
  48.                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  49.                 return o;
  50.             }
  51.            
  52.             fixed4 frag (v2f i) : SV_Target {
  53.                 fixed4 col = tex2D(_MainTex, i.uv) * _TintColor;
  54.  
  55.                 if(i.vertex.y<_Height){
  56.                     float y = i.vertex.y;
  57.                     col.a = 1-_Transparency*(_Height-y);
  58.                 }
  59.  
  60.                 return col;
  61.             }
  62.             ENDCG
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement