SimpleVertexShader.hlsl 661 B

1234567891011121314151617181920212223242526272829303132333435
  1. cbuffer ModelViewProjectionConstantBuffer : register(b0)
  2. {
  3. matrix model;
  4. matrix view;
  5. matrix projection;
  6. };
  7. struct VertexShaderInput
  8. {
  9. float3 pos : POSITION;
  10. float3 color : COLOR0;
  11. };
  12. struct VertexShaderOutput
  13. {
  14. float4 pos : SV_POSITION;
  15. float3 color : COLOR0;
  16. };
  17. VertexShaderOutput mainVS(VertexShaderInput input)
  18. {
  19. VertexShaderOutput output;
  20. float4 pos = float4(input.pos, 1.0f);
  21. // Transform the vertex position into projected space.
  22. pos = mul(pos, model);
  23. pos = mul(pos, view);
  24. pos = mul(pos, projection);
  25. output.pos = pos;
  26. // Pass through the color without modification.
  27. output.color = input.color;
  28. return output;
  29. }