;vs.1.0
; Constants:
;
;  c0-c3  - View+Projection matrix
;
;  c4.x   - lightsize
;  c4.y   - 0.5
;  c4.z   - 0
;  c4.w   -
; 
;  c5-light
;  c6-
;
;

;vertex shader for grass..
;sinusoidal vertex motion for waving grass
;pos + sumOverI(wavedirI * texcoordy * sin( xdirI * (xpos+time)) + ydirI * (ypos+time)))
;SetVertexShaderConstant 0 commonConst
;SetVertexShaderConstant 1 appConst
;SetVertexShaderConstant 2 worldSpaceCamPos
;SetVertexShaderConstant 4 wvp
;SetVertexShaderConstant 8 sin9
;SetVertexShaderConstant 10 frcFixup
;SetVertexShaderConstant 11 waveDistortx
;SetVertexShaderConstant 12 waveDistorty
;SetVertexShaderConstant 13 waveDistortz
;SetVertexShaderConstant 14 waveDirx
;SetVertexShaderConstant 15 waveDiry
;SetVertexShaderConstant 16 waveSpeed
;SetVertexShaderConstant 17 piVector
;SetVertexShaderConstant 18 lightingWaveScale
;SetVertexShaderConstant 19 lightingScaleBias
;StartVertexShader

vs.1.1
;use vertex pos x as inputs to sinusoidal warp
mul r0, c14, v0.x 

;use vertex pos y as inputs to sinusoidal warp
mad r0, c15, v0.y, r0

;get current time
mov r1, c1.x

;add scaled time to move bumps according to speed
mad r0, r1, c16, r0

;take frac of all 4 components
frc r0.xy, r0
frc r1.xy, r0.zwzw 
mov r0.zw, r1.xyxy 

;multiply by fixup factor (due to inaccuracy of taylor series)
;mul r0, r0, c10.x

;subtract 0.5
sub r0, r0, c0.y

;*=2pi coords range from(-pi to pi)
mul r1, r0, c17.w
;(wave vec)^2
mul r2, r1, r1
;(wave vec)^3
mul r3, r2, r1
;(wave vec)^5
mul r5, r3, r2
;(wave vec)^7
mul r7, r5, r2
;(wave vec)^9
;mul r9, r7, r2
;(wave vec) - ((wave vec)^3)/3!
mad r0, r3, c8.x, r1
;+ ((wave vec)^5)/5!
mad r0, r5, c8.y, r0
;- ((wave vec)^7)/7!
mad r0, r7, c8.z, r0
;- ((wave vec)^9)/9!
;mad r0, r9, c8.w, r0

//sub r9.x,c0.x,v7.y

dp4 r3, r0, c11
//dp4 r3.y, r0, c12
//dp4 r3.zw, r0, c13
//mul r4, v7.y, v7.y
;attenuate sinusoidal warping by tex0.y^2
mul r3, r3, v7.y
mov r2.w, v0
;add sinusoidal warping to grass position
add r2.xyz, r3, v0
m4x4 oPos, r2, c4
;scale and add sin waves together
//dp4 r1.x, r0, c18
;scale and bias color values (green is scaled more // than red and blue)
//mad oD0, c19.xzxz, -r1.x, c19.y
mov oD0, v5
mov oT0, v7

;EndVertexShader
