hi, i've just written my first shader, it's for displaying a waving flag. here's the code:
if someone with more experience could check my code and has any suggestions on how to improve it, i'd be very grateful
Code:
Shader "Selfmade/FlagWave" { Properties { _MainTex ("Texture", 2D) = "white" { } } SubShader { Pass { CULL Off CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" #include "AutoLight.cginc" float4 _Color; sampler2D _MainTex; //float4 _Time; // vertex input: position, normal struct appdata { float4 vertex : POSITION; float4 texcoord : TEXCOORD0; }; struct v2f { float4 pos : POSITION; float2 uv: TEXCOORD0; }; v2f vert (appdata v) { v2f o; float angle= _Time * 50; v.vertex.y = v.texcoord.x * sin(v.vertex.x + angle); v.vertex.y += sin(v.vertex.z / 2 + angle); v.vertex.y *= v.vertex.x * 0.1f; o.uv = v.texcoord; return o; } float4 frag (v2f i) : COLOR { half4 color = tex2D(_MainTex, i.uv); return color; } ENDCG //SetTexture [_MainTex] {combine texture} } } Fallback "VertexLit" }
thx

Reply With Quote


