Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.15 KB | None | 0 0
  1. Shader "Unlit/Billboard" {
  2.    
  3.     Properties{
  4.         _MainTex("Texture Image", 2D) = "white" {}
  5.         _ScaleX("Scale X", Float) = 1.0
  6.         _ScaleY("Scale Y", Float) = 1.0
  7.         _CutOff ("Alpha Cutoff", Range(0,1)) = 0.5
  8.     }
  9.  
  10.     SubShader{
  11.         Pass{
  12.  
  13.             CGPROGRAM
  14.             #pragma vertex vert  
  15.             #pragma fragment frag
  16.  
  17.             // User-specified uniforms            
  18.             uniform sampler2D _MainTex;
  19.             uniform float _ScaleX;
  20.             uniform float _ScaleY;
  21.             uniform float _CutOff;
  22.  
  23.             struct vertexInput {
  24.                 float4 vertex : POSITION;
  25.                 float4 tex : TEXCOORD0;
  26.             };
  27.             struct vertexOutput {
  28.                 float4 pos : SV_POSITION;
  29.                 float4 tex : TEXCOORD0;
  30.             };
  31.  
  32.             vertexOutput vert(vertexInput input)
  33.             {
  34.                 vertexOutput output;
  35.  
  36.                 output.pos = mul(UNITY_MATRIX_P,
  37.                     mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
  38.                     + float4(input.vertex.x, input.vertex.y, 0.0, 0.0)
  39.                     * float4(_ScaleX, _ScaleY, 1.0, 1.0));
  40.  
  41.                 output.tex = input.tex;
  42.  
  43.                 return output;
  44.             }
  45.  
  46.             float4 frag(vertexOutput input) : COLOR
  47.             {
  48.                 float4 color = tex2D(_MainTex, float2(input.tex.xy));
  49.  
  50.                 if (color.a < _CutOff) discard;
  51.  
  52.                 return color;
  53.             }
  54.  
  55.             ENDCG
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement