build-surface.azsl 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. [[global::output_format("R16G16B16A16_FLOAT")]]
  9. [[global::output_format(0, "R32")]]
  10. [[global::output_format(1, "R32G32")]]
  11. [[global::output_format(2, "R32A32")]]
  12. [[global::output_format(3, "R16G16B16A16_UNORM")]]
  13. [[global::output_format(4, "R16G16B16A16_SNORM")]]
  14. [[global::output_format(5, "R16G16B16A16_UINT")]]
  15. [[global::output_format(6, "R16G16B16A16_SINT")]]
  16. [[global::output_format(7, "R32G32B32A32")]]
  17. struct VertexInput { float3 m_position : POSITION; };
  18. struct VertexOutput { float4 m_position : SV_Position; };
  19. ShaderResourceGroupSemantic ExampleBinding { FrequencyId = 0; };
  20. rootconstant float3 varFloat3;
  21. rootconstant float4 varFloat4;
  22. rootconstant float3x3 mat3x3;
  23. ShaderResourceGroup ExampleSRG : ExampleBinding
  24. {
  25. struct JustForPacking
  26. {
  27. row_major float2x3 m_rowMatrix;
  28. column_major float2x3 m_columnMatrix;
  29. float m_someScalar;
  30. float2 m_somePair;
  31. float4 m_someVector;
  32. };
  33. struct ModelStruct
  34. {
  35. row_major float4x4 m_modelToWorld;
  36. };
  37. ConstantBuffer<ModelStruct> m_modelConstants;
  38. ConstantBuffer<JustForPacking> m_arrayOfFour[4];
  39. ModelStruct m_myModel;
  40. row_major float2x3 m_rowMajorConst;
  41. column_major float2x3 m_colMajorConst;
  42. float4 m_srgConstVectorArray[15];
  43. float4 m_srgConstVector;
  44. float m_srgConstScalarArray[7];
  45. float m_srgConstScalar;
  46. Texture2D m_diffuseMap;
  47. struct UserStruct
  48. {
  49. int partial_;
  50. float m_myFloat;
  51. double m_myDouble;
  52. bool m_myBool;
  53. };
  54. AppendStructuredBuffer<UserStruct> m_bufferView1;
  55. ConsumeStructuredBuffer<UserStruct> m_bufferView2;
  56. ByteAddressBuffer m_bufferView4;
  57. StructuredBuffer<UserStruct> m_bufferView5;
  58. RWBuffer<float4> m_bufferView6;
  59. RWByteAddressBuffer m_bufferView7;
  60. RWStructuredBuffer<UserStruct> m_bufferView8a;
  61. Sampler m_sampler
  62. {
  63. MaxAnisotropy = 16;
  64. AddressU = Wrap;
  65. AddressV = Wrap;
  66. AddressW = Wrap;
  67. MinFilter = Point;
  68. MagFilter = Linear;
  69. MipFilter = Point;
  70. ReductionType = Filter;
  71. };
  72. Sampler m_dynamicSampler;
  73. };
  74. VertexOutput MainVS(VertexInput input)
  75. {
  76. VertexOutput output;
  77. output.m_position = mul(ExampleSRG::m_modelConstants.m_modelToWorld, float4(input.m_position, 1.0));
  78. output.m_position = varFloat4 * output.m_position;
  79. return output;
  80. }
  81. struct VertexInput2 {
  82. float3 m_position : POSITION;
  83. float m_color[4] : COLOR;
  84. float4 a1 : TEXCOORD0;
  85. float4 a2[2] : TEXCOORD1;
  86. float4 a3[2][3] : TEXCOORD2;
  87. };
  88. VertexOutput MainVS2(VertexInput2 input)
  89. {
  90. VertexOutput output;
  91. output.m_position = mul(ExampleSRG::m_modelConstants.m_modelToWorld, float4(input.m_position, 1.0));
  92. return output;
  93. }
  94. float4 MainPS() : SV_Target0
  95. {
  96. float4 baseColor = ExampleSRG::m_diffuseMap.Sample(ExampleSRG::m_sampler, float2(0.5, 0.5));
  97. baseColor = float4(varFloat3, 1.0f);
  98. return baseColor + ExampleSRG::m_arrayOfFour[2].m_someVector + ExampleSRG::m_srgConstVectorArray[3];
  99. }