TexturedSurface.azsl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 TexturedSurfaceSrg : SRG_PerObject
  10. {
  11. row_major float4x4 m_worldMatrix;
  12. row_major float4x4 m_viewProjectionMatrix;
  13. float m_alphaTestRefValue;
  14. Texture2D<float4> m_albedoMap;
  15. Sampler m_sampler
  16. {
  17. MaxAnisotropy = 16;
  18. AddressU = Wrap;
  19. AddressV = Wrap;
  20. AddressW = Wrap;
  21. };
  22. }
  23. struct VSInput
  24. {
  25. float3 m_position : POSITION;
  26. float2 m_uv : UV0;
  27. };
  28. struct VSOutput
  29. {
  30. float4 m_position : SV_Position;
  31. float2 m_uv : UV0;
  32. };
  33. VSOutput MainVS(VSInput vsInput)
  34. {
  35. VSOutput OUT;
  36. float4 worldPosition = mul(TexturedSurfaceSrg::m_worldMatrix, float4(vsInput.m_position, 1.0));
  37. OUT.m_position = mul(TexturedSurfaceSrg::m_viewProjectionMatrix, worldPosition);
  38. OUT.m_uv.x = vsInput.m_uv.x;
  39. OUT.m_uv.y = 1.0 - vsInput.m_uv.y;
  40. return OUT;
  41. }
  42. struct PSOutput
  43. {
  44. float4 m_color : SV_Target0;
  45. };
  46. PSOutput MainPS(VSOutput psInput)
  47. {
  48. PSOutput OUT;
  49. OUT.m_color = TexturedSurfaceSrg::m_albedoMap.Sample(TexturedSurfaceSrg::m_sampler, psInput.m_uv).rgba;
  50. clip( OUT.m_color.a < TexturedSurfaceSrg::m_alphaTestRefValue ? -1 : 1 );
  51. return OUT;
  52. }