SimpleVertexShader.hlsl 1023 B

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