vs.1.1 // version instruction // Scale the vertex position by the heightmap dimensions mul r0, v0, c[8] // 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 mul r1, v0.xzww, c[9] // Convert the vertex's XZ position into a UV coordinate sub r1.y, c[9].y, r1.y // Flip the V coordinate mov oT0, r1 // Set up UV stage 0 mov oT1, r1 // Set up UV stage 1 mov oT2, r1 // Set up UV stage 2 mov oT3, r1 // Set up UV stage 3 // Generate a greyscale color for this vertex. Black means Y==0, White means // Y==the highest point on the heightmap. Since our vertex position is passed // in to v0 normalized from 0..1, all we need to do is copy its Y coordinate // into the Diffuse's RGB values. mov oD0, v0.yyyw