vs.1.1 ; version instruction mov oD0, v1 ; Diffuse color ; ______________________________________________________ ; Get the x and z index, from -32768 to 32767 and add 32768 to bring back to 0 - 65535 ;add r0.xyzw, v1.xzyz, c[16].wywy ; r0.xyzw = (x 0 z 0) + (32768.0f 1.0 32768.0f 1.0) ;mov r0.y, v0.x ; Get the terrain height for that vertex from v0 ; Bring r0 in world space multiplying by terrain square size. ;mul r0.xyz, r0.xyz, c[16].xyz ; ______________________________________________________ ; r0.x = v0.x * TileI ; r0.z = v0.y * TileJ ; r0.y = v0.z * 256.0f + v1.w mul r0, v0, c[50].yyyy mul r0.xz, r0.xz, c[16].xz add r0.xz, r0.xz, c[50].xz mul r0.y, v0.y, c[50].w mov r0.w, c[8].ww ;mad r0.y, v0.w, c[50].y, r0.y ;add r0.y, r0.y, v1.w ;mov r0.y, c[50].w ; r0.x *= square size ; r0.z *= square size ;mul r0.xz, r0.xz, c[16].xz ; r0.y *= m_Dimensions.y ;mul r0.y, r0.y, c[8].y ; Store r0 into 0..1 space in r4, for the texture coordinates later, mul r4, r0, c[17] ; r4 = r0 * 1/mTerrainDimension ; Transform the vertex position dp4 oPos.x, r0, c[0] ; Matrix multiply row 0 dp4 oPos.y, r0, c[1] ; Matrix multiply row 1 dp4 oPos.z, r0, c[2] ; Matrix multiply row 2 dp4 oPos.w, r0, c[3] ; Matrix multiply row 3 dp4 r11.x, r0, c[2] ; Fog mul oFog.x, r11.x, c11.x ; r4 has to be a value between 0.0f and 1.0f. ; calculate the tiling of the terrain texture and the lightmap mul r1, r4.xzww, c[9] sub r1.y, c[9].y, r1.y ; Transform the texture coordinates dp4 r0.x, r1, c[4] ; Transform the UVs dp4 r0.y, r1, c[5] ; Transform the UVs dp4 r0.z, r1, c[6] ; Transform the UVs dp4 r0.w, r1, c[7] ; Transform the UVs mov oT0, r0 ; Set up UV stage 0 mov oT1, r0 ; Set up UV stage 1 mov oT2, r0 ; Set up UV stage 2 mov oT3, r0 ; Set up UV stage 3