Advertisement
dnnkeeper

Unity PortalView shader

Apr 14th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. Shader "Custom/TextureCoordinates/PortalView" {
  2.      Properties {
  3.        _MainTex ("Texture", 2D) = "white" {}
  4.        _Mask ("Mask", 2D) = "white" {}
  5.        _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
  6.      }
  7.      SubShader
  8.      {
  9.         Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
  10.         LOD 200
  11.         Cull Back
  12.         CGPROGRAM
  13.         #pragma surface surf Unlit alphatest:_Cutoff
  14.  
  15.         sampler2D _MainTex,_Mask;
  16.        
  17.         struct Input {
  18.             float2 uv_MainTex;
  19.             float4 screenPos;
  20.         };
  21.  
  22.         fixed4 LightingUnlit(SurfaceOutput s, fixed3 lightDir, fixed atten)
  23.         {
  24.              fixed4 c;
  25.              c.rgb = s.Albedo;
  26.              c.a = s.Alpha;
  27.              return c;
  28.         }
  29.  
  30.         inline fixed4 LightingUnlit_PrePass (SurfaceOutput s, half4 light)
  31.         {
  32.             fixed4 c;
  33.             c.rgb = s.Albedo;
  34.             c.a = s.Alpha;
  35.             return c;
  36.         }
  37.  
  38.         void surf (Input IN, inout SurfaceOutput o) {
  39.             half4 c = tex2D (_MainTex, IN.screenPos.xy / IN.screenPos.w);
  40.             o.Albedo = c.rgb;
  41.             o.Alpha = tex2D (_Mask, IN.uv_MainTex).a;
  42.            
  43.         }
  44.         ENDCG
  45.      }
  46.      Fallback "Legacy Shaders/Transparent/Cutout/VertexLit"
  47.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement