I used this shader for my flag , It works correctly but when I duplicate It distortion will happen In game (this is mean It works just for single flag).how can I use my shader for multiple flags with same material. I think this Is bug because there is no reason for distorting here:
Shader "Custom/Flag" {
Properties {
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Speed ("Speed", Range(0, 5.0)) = 1
_Frequency ("Frequency", Range(0, 1.3)) = 1
_Amplitude ("Amplitude", Range(0, 5.0)) = 1
}
SubShader {
Tags { "RenderType"="Opaque" }
Cull off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
float4 _MainTex_ST;
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
float _Speed;
float _Frequency;
float _Amplitude;
v2f vert(appdata_base v)
{
v2f o;
v.vertex.y += cos((v.vertex.x + _Time.y * _Speed) * _Frequency) * _Amplitude * (v.vertex.x - 5);
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
return tex2D(_MainTex, i.uv);
}
ENDCG
}
}
FallBack "Diffuse"
}