Shader "WavedFlag"
{
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_WaveSpeed ("Wave Speed", float) = 50.0
_Distortion ("Flag Distortion", Range(0.01,1)) = 0.05
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CULL Off
CGPROGRAM
#pragma surface surf Lambert vertex:vert addshadow
sampler2D _MainTex;
float4 _Color;
struct Input
{
float2 uv_MainTex;
};
float _WaveSpeed;
float _Distortion;
void vert (inout appdata_full v)
{
float sinOff = v.vertex.x + v.vertex.y + v.vertex.z;
float t = _Time * _WaveSpeed;
if (t < 0.0) t *= -1.0;
float fx = v.texcoord.x;
float fy = v.texcoord.x * v.texcoord.y;
//v.vertex.x += sin(t * 1.45 + sinOff) * fx * 5 * _Distortion;
v.vertex.y = sin(t * 3.12 + sinOff) * fx * 5 * _Distortion - fy * 9 * _Distortion;
//v.vertex.z -= sin(t * 2.2 + sinOff) * fx * 2 * _Distortion;
}
void surf (Input IN, inout SurfaceOutput o)
{
float4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "VertexLit"
}