Texture.vs 1.3 KB

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