AuxGeomWorld.azsl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 <viewsrg_all.srgi>
  9. ShaderResourceGroup PerDrawSrg : SRG_PerDraw
  10. {
  11. row_major float4x4 m_viewProjectionOverride;
  12. float m_pointSize;
  13. }
  14. option enum class ViewProjectionMode { ViewProjection, ManualOverride } o_viewProjMode;
  15. struct VSInput
  16. {
  17. float3 m_position : POSITION;
  18. float4 m_color : COLOR;
  19. };
  20. struct VSOutput
  21. {
  22. float4 m_position : SV_Position;
  23. float4 m_color : COLOR;
  24. [[vk::builtin("PointSize")]]
  25. float m_pointSize : PSIZE;
  26. };
  27. VSOutput MainVS(VSInput vsInput)
  28. {
  29. VSOutput OUT;
  30. if (o_viewProjMode == ViewProjectionMode::ViewProjection)
  31. {
  32. OUT.m_position = mul(ViewSrg::m_viewProjectionMatrix, float4(vsInput.m_position.xyz, 1.0));
  33. }
  34. else if (o_viewProjMode == ViewProjectionMode::ManualOverride)
  35. {
  36. OUT.m_position = mul(PerDrawSrg::m_viewProjectionOverride, float4(vsInput.m_position.xyz, 1.0));
  37. }
  38. OUT.m_color = vsInput.m_color;
  39. // On Vulkan you need to specify the point size in the VS when using the point topology.
  40. OUT.m_pointSize = PerDrawSrg::m_pointSize;
  41. return OUT;
  42. }
  43. struct PSOutput
  44. {
  45. float4 m_color : SV_Target0;
  46. };
  47. PSOutput MainPS(VSOutput input)
  48. {
  49. PSOutput OUT;
  50. OUT.m_color = input.m_color;
  51. return OUT;
  52. }