DualSourceBlending.azsl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 DualSourceBlendingSrg : SRG_PerObject
  10. {
  11. float m_blendFactor;
  12. }
  13. struct VSInput
  14. {
  15. float3 m_position : POSITION;
  16. float4 m_color : COLOR;
  17. };
  18. struct VSOutput
  19. {
  20. float4 m_position : SV_Position;
  21. float4 m_color : COLOR;
  22. };
  23. VSOutput MainVS(VSInput vsInput)
  24. {
  25. VSOutput OUT;
  26. OUT.m_position = float4(vsInput.m_position, 1.0);
  27. OUT.m_color = vsInput.m_color;
  28. return OUT;
  29. }
  30. struct PSOutput
  31. {
  32. [[vk::location(0), vk::index(0)]]
  33. float4 m_color0 : SV_Target0;
  34. [[vk::location(0), vk::index(1)]]
  35. float4 m_color1 : SV_Target1;
  36. };
  37. PSOutput MainPS(VSOutput psInput)
  38. {
  39. PSOutput OUT;
  40. OUT.m_color0 = psInput.m_color;
  41. OUT.m_color1 = float4(DualSourceBlendingSrg::m_blendFactor, DualSourceBlendingSrg::m_blendFactor, DualSourceBlendingSrg::m_blendFactor, 1.0);
  42. // Set in BlendState
  43. // FinalColor = SourceColor * SourceColor1 + DestColor * (1 - SourceColor1)
  44. return OUT;
  45. }