IndirectDraw.azsl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "IndirectRendering.azsli"
  9. struct VSInput
  10. {
  11. float3 m_position : POSITION;
  12. uint m_instanceId : BLENDINDICES0;
  13. };
  14. struct VSOutput
  15. {
  16. float4 m_position : SV_Position;
  17. float4 m_color : COLOR;
  18. };
  19. rootconstant uint g_instanceId;
  20. option bool o_useRootConstants = false;
  21. VSOutput MainVS(VSInput vsInput)
  22. {
  23. VSOutput OUT;
  24. uint instanceId;
  25. if (o_useRootConstants)
  26. {
  27. instanceId = g_instanceId;
  28. }
  29. else
  30. {
  31. instanceId = vsInput.m_instanceId;
  32. }
  33. float4 position = float4(TransformInstancePos(vsInput.m_position, IndirectSceneSrg::m_instancesData[instanceId]), 1.0);
  34. OUT.m_position = mul(IndirectSceneSrg::m_matrix, position);
  35. float intensity = saturate((4.0f - OUT.m_position.z) / 2.0f);
  36. OUT.m_color = float4(IndirectSceneSrg::m_instancesData[instanceId].m_color.xyz * intensity, 1.0f);
  37. return OUT;
  38. }
  39. struct PSOutput
  40. {
  41. float4 m_color : SV_Target0;
  42. };
  43. PSOutput MainPS(VSOutput vsOutput)
  44. {
  45. PSOutput OUT;
  46. OUT.m_color = vsOutput.m_color;
  47. return OUT;
  48. }