//
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.08.299.0000
//
//   vsa shaderdump19/GRASS2042.vso /Fcshaderdump19/GRASS2042.vso.dis
//
//
// Parameters:
//
float4 AlphaParam : register(c5);
float4 EyeVector : register(c13);
float4 FogColor : register(c14);
float4 FogParam : register(c15);
float4 InstanceData[2] : register(c20);
row_major float4x4 ModelViewProj : register(c9);
float4 ObjToCube0 : register(c0);
float4 ObjToCube1 : register(c1);
float4 ObjToCube2 : register(c3);
float4 ObjToCube3 : register(c6);
float3 ScaleMask : register(c2);
float4 WindData : register(c4);

//
//
// Registers:
//
//   Name          Reg   Size
//   ------------- ----- ----
//   ObjToCube0    const_0       1
//   ObjToCube1    const_1       1
//   ScaleMask     const_2       1
//   ObjToCube2    const_3       1
//   WindData      const_4       1
//   AlphaParam    const_5       1
//   ObjToCube3    const_6       1
//   ModelViewProj[0] const_9        1
//   ModelViewProj[1] const_10        1
//   ModelViewProj[2] const_11        1
//   ModelViewProj[3] const_12        1
//   EyeVector     const_13      1
//   FogColor      const_14      1
//   FogParam      const_15      1
//   InstanceData[0]  const_20       1
//   InstanceData[1]  const_21       1
//


// Structures:

struct VS_INPUT {
    float4 position : POSITION;
    float4 color_0 : COLOR0;
    float4 texcoord_0 : TEXCOORD0;
    float4 texcoord_1 : TEXCOORD1;
};

struct VS_OUTPUT {
    float4 color_0 : COLOR0;
    float4 position : POSITION;
    float2 texcoord_0 : TEXCOORD0;
    float4 texcoord_1 : TEXCOORD1;
    float4 texcoord_2 : TEXCOORD2;
    float4 texcoord_4 : TEXCOORD4;
    float4 texcoord_5 : TEXCOORD5;
};

// Code:

VS_OUTPUT main(VS_INPUT IN) {
    VS_OUTPUT OUT;

#define	PI			3.14159274
#define	anglei(v)		(((v) + PI) / (2 * PI))
#define	angler(v)		(((v) * (2 * PI)) - PI)
#define	fracr(v)		angler(frac(anglei(v)))	// signed modulo % PI
#define	sqr(v)			((v) * (v))

    float4 const_7 = {0.01, 0.8, -1, 0};

    float1 q0;
    float4 q1;
    float4 r0;
    float4 r1;
    float3 r2;
	float3 scale;
	
    r0.xy = sqr(EyeVector.xy);
    r2.xy = const_7.xy;
    r1.xz = -EyeVector.xy / sqrt(r0.y + r0.x);
    r1.yw = r1.z * const_7.zw;
    r0.xyz = r1.zxw * const_7.zyy;
    r1.xy = r0.xy / sqrt(dot(r1.yxw, r0.xyz));
    r0.w = r1.x;
    q0.x = ((InstanceData[0 + IN.texcoord_1.x].y + InstanceData[0 + IN.texcoord_1.x].x) / 128) + WindData.w;
	scale.xyz = ScaleMask.xyz;
    r2.xyz = (((r2.x * InstanceData[0 + IN.texcoord_1.x].w) * scale.xyz) + r2.y) * IN.position.xyz;
    r1.y = dot(r1.yzw, r2.xyz);
    r1.x = dot(r0.wyz, r2.xyz);
    r0.z = r2.z;
    r0.w = IN.position.w;
    r0.xy = (((sin(fracr(q0.x)) * WindData.z) * sqr(IN.color_0.a)) * WindData.xy) + r1.xy;
    r0.xyz = r0.xyz + InstanceData[0 + IN.texcoord_1.x].xyz;
    r1.xyz = mul(float3x4(ModelViewProj[0].xyzw, ModelViewProj[1].xyzw, ModelViewProj[2].xyzw), r0.xyzw);
    r1.w = dot(ModelViewProj[3].xyzw, r0.xyzw);
    r2.xy = saturate((length(r1.xyzw) - AlphaParam.xz) / AlphaParam.yw);
    OUT.color_0.rgb = FogColor.rgb;
    OUT.color_0.a = 1 - saturate((FogParam.x - length(r1.xyz)) / FogParam.y);
    OUT.position.xyzw = r1.xyzw;
    OUT.texcoord_0.xy = IN.texcoord_0.xy;
    q1.xyzw = (r0.xyzx * const_7.yyyw) + const_7.wwwy;
    OUT.texcoord_1.xyzw = mul(float4x4(ObjToCube0.xyzw, ObjToCube1.xyzw, ObjToCube2.xyzw, ObjToCube3.xyzw), q1.xyzw);
    OUT.texcoord_2.xyzw = q1.xyzw;
    OUT.texcoord_4.xyzw = 0;
    OUT.texcoord_5.w = r2.x * (1 - r2.y);
    OUT.texcoord_5.xyz = 0;

    return OUT;
};

// approximately 75 instruction slots used
