Advertisement
Guest User

序列幀動畫Shader]

a guest
Jul 2nd, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. Shader "Custom/Animation_00" {
  2.     Properties {
  3.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
  4.         _OnePictureLength("onePictureLength",float) = 0.1667
  5.         _Cutoff("alpha",range(0,1))=0.5
  6.     }
  7.     SubShader {
  8.         Tags { "RenderType"="Opaque" "Queue"="Transparent"}  
  9.         //AlphaTest Greater [_alpha]
  10.         ZWrite off
  11.         blend SrcAlpha OneMinusSrcAlpha
  12.         LOD 200
  13.        
  14.         CGPROGRAM
  15.        
  16.         #pragma surface surf Lambert alphatest:_Cutoff
  17.  
  18.         sampler2D _MainTex;
  19.         int i;
  20.         float _OnePictureLength;
  21.  
  22.         struct Input {
  23.             float2 uv_MainTex;
  24.         };
  25.  
  26.         void surf (Input IN, inout SurfaceOutput o)
  27.         {      
  28.             // 四捨五入
  29.             i = round(_Time.w);
  30.             float2 uv = IN.uv_MainTex;
  31.             // 填入 1/圖片數量數字,看是橫的或是直的。
  32.             uv *= float2(_OnePictureLength,1);
  33.             uv += float2(i*_OnePictureLength,0);
  34.  
  35.             fixed4 c = tex2D (_MainTex, uv);
  36.             o.Albedo = c.rgb;
  37.             o.Alpha = c.a;
  38.         }
  39.         ENDCG
  40.     }
  41.     FallBack "Diffuse"
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement