vs.1.1 ; version instruction ; Get the x and z index, from -32768 to 32767 and add 32768 to bring back to 0 - 65535 add r1.xyzw, v1.xzyz, c[16].wywy ; r1.xyzw = (x 0 z 0) + (32768.0f 1.0 32768.0f 1.0) mov r1.y, v0.x ; Get the terrain height for that vertex from v0 ; Bring r1 in world space multiplying by terrain square size. mul r1.xyz, r1.xyz, c[16].xyz // Transform the vertex position dp4 oPos.x, r1, c[0] ; Matrix multiply row 0 dp4 oPos.y, r1, c[1] ; Matrix multiply row 1 dp4 oPos.z, r1, c[2] ; Matrix multiply row 2 dp4 oPos.w, r1, c[3] ; Matrix multiply row 3 //mov r0, -v0 sub r0, r1, c[5] ; r0 = vertex position - shadow center //add r0, c[5], v0 ; r0 = vertex position - shadow center mul r0, r0, c[6] ; r0 = r0 / shadow radius //sub r0, c[8], r0 add r0, r0, c[7] ; r0 = r0 + 0.5 mov oT0.xyz, r0.xzy // Apply lighting to the vertex color mov oD0, c[4] ; Diffuse