struct VIn { float4 p : POSITION; float3 n : NORMAL; float2 uv : TEXCOORD0; float3 c : COLOR0; }; struct VOut { float4 p : POSITION; float2 uv : TEXCOORD0; float3 c : COLOR0; }; VOut grass_vs(VIn IN, uniform float4x4 wvpMat, uniform float4x4 iwpMat, uniform float time, uniform float3 amplitude, uniform float4 eyePosition, uniform float3 ambientColor, uniform float4 lightPosition, uniform float4 lightAttenuation, uniform float3 lightDiffuseColor, uniform float3 Ke, uniform float3 Ka, uniform float3 Kd, uniform float3 Ks, uniform float shininess) { VOut OUT; float4 np = mul(wvpMat, IN.p); if (IN.uv.y < 0.9) { np.z += cos(time)* (1.0 - IN.uv.y) * amplitude.x; np.y += cos(time)* (1.0 - IN.uv.y) * amplitude.y; np.x += cos(time)* (1.0 - IN.uv.y) * amplitude.z; }; OUT.p = np; OUT.uv = IN.uv; // light float3 tmpcolor = IN.c; lightPosition = mul(iwpMat, lightPosition); eyePosition = mul(iwpMat, eyePosition); float3 N = normalize(IN.n); float3 emissive = Ke; float3 ambient = Ka * ambientColor; float3 L = normalize(lightPosition); float diffuseLight = max(dot(L, N), 0); float3 diffuse = Kd * lightDiffuseColor * diffuseLight; float3 V = normalize(eyePosition); float3 H = normalize(L + V); float specularLight = pow(max(dot(H, N), 0), shininess); if (diffuseLight <= 0) specularLight = 0; float3 specular = Ks * lightDiffuseColor * specularLight; tmpcolor.xyz = emissive + ambient + specular + diffuse; OUT.c = tmpcolor; return OUT; }