Animated Leaf.shader
767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Shader "Custom/Animated Leaf" {
Properties {
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_OffsetY ("Offset Y",Range(0,0.1)) = 0.05
_TimeRatio("Time Ratio", Range(0,5)) = 1
}
SubShader {
Tags { "Queue" = "AlphaTest" "RenderType"="TransparentCutout" }
cull off
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff vertex:vert noshadow
sampler2D _MainTex;
float _OffsetY;
float _TimeRatio;
struct Input {
float2 uv_MainTex;
};
void vert(inout appdata_full v)
{
v.vertex.y += sin(_Time.y * _TimeRatio) * _OffsetY * v.texcoord.x * v.texcoord.y;
}
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}