Triangle.azsl 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Atom/Features/SrgSemantics.azsli>
  9. ShaderResourceGroup PassSrg : SRG_PerPass
  10. {
  11. column_major float4x4 m_objectMatrix;
  12. }
  13. struct VSInput
  14. {
  15. uint m_vertexID : SV_VertexID;
  16. };
  17. struct VSOutput
  18. {
  19. float4 m_position : SV_Position;
  20. float4 m_color : COLOR0;
  21. };
  22. VSOutput MainVS(VSInput vsInput)
  23. {
  24. VSOutput OUT;
  25. switch(vsInput.m_vertexID)
  26. {
  27. case 0:
  28. OUT.m_position = float4(0.0, 0.5, 0.0, 1.0);
  29. OUT.m_color = float4(1.0, 0.0, 0.0, 1.0);
  30. break;
  31. case 1:
  32. OUT.m_position = float4(-0.5, -0.5, 0.0, 1.0);
  33. OUT.m_color = float4(0.0, 1.0, 0.0, 1.0);
  34. break;
  35. default:
  36. OUT.m_position = float4(0.5, -0.5, 0.0, 1.0);
  37. OUT.m_color = float4(0.0, 0.0, 1.0, 1.0);
  38. break;
  39. }
  40. OUT.m_position = mul(PassSrg::m_objectMatrix, OUT.m_position);
  41. return OUT;
  42. }
  43. struct PSOutput
  44. {
  45. float4 m_color : SV_Target0;
  46. };
  47. PSOutput MainPS(VSOutput vsOutput)
  48. {
  49. PSOutput OUT;
  50. OUT.m_color = vsOutput.m_color;
  51. // Simple tonemapping:
  52. OUT.m_color.rgb = pow(OUT.m_color.rgb, 1.0/2.2);
  53. return OUT;
  54. }