1 cbuffer ModelViewProjectionConstantBuffer : register(b0) 2 { 3 matrix model; 4 matrix view; 5 matrix projection; 6 }; 7 8 struct VertexInputType 9 { 10 float4 position : POSITION; 11 float2 tex : TEXCOORD0; 12 }; 13 14 struct PixelInputType 15 { 16 float4 position : SV_POSITION; 17 float2 tex : TEXCOORD0; 18 }; 19 20 21 //////////////////////////////////////////////////////////////////////////////// 22 // Vertex Shader 23 //////////////////////////////////////////////////////////////////////////////// 24 PixelInputType main(VertexInputType input) 25 { 26 PixelInputType output; 27 28 // Change the position vector to be 4 units for proper matrix calculations. 29 input.position.w = 1.0f; 30 31 // Calculate the position of the vertex against the world, view, and projection matrices. 32 output.position = mul(input.position, model); 33 output.position = mul(output.position, view); 34 output.position = mul(output.position, projection); 35 // Store the texture coordinates for the pixel shader. 36 output.tex = input.tex; 37 38 return output; 39 } 40