ordering-srg-function.azsl 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. ShaderResourceGroupSemantic SRG_PerView
  9. {
  10. FrequencyId = 4;
  11. };
  12. ShaderResourceGroup ViewSrg : SRG_PerView
  13. {
  14. row_major float4x4 m_viewProjectionMatrix;
  15. row_major float4x4 m_viewMatrix;
  16. row_major float4x4 m_projectionMatrix;
  17. float3 m_worldPosition;
  18. // precached depth constants for faster evaluation
  19. // x -> NearZ
  20. // y -> FarZ
  21. // z -> FarZ * NearZ
  22. // w -> FarZ - NearZ
  23. float4 m_zConstants;
  24. float3 GetWorldPosition()
  25. {
  26. return m_worldPosition;
  27. }
  28. float4x4 GetViewProjectionMatrix()
  29. {
  30. return m_viewProjectionMatrix;
  31. }
  32. float4x4 GetViewMatrix()
  33. {
  34. return m_viewMatrix;
  35. }
  36. float4x4 GetProjectionMatrix()
  37. {
  38. return m_projectionMatrix;
  39. }
  40. float GetNearZ()
  41. {
  42. return m_zConstants.x;
  43. }
  44. float GetFarZ()
  45. {
  46. return m_zConstants.y;
  47. }
  48. float GetFarZTimesNearZ()
  49. {
  50. return m_zConstants.z;
  51. }
  52. float GetFarZMinusNearZ()
  53. {
  54. return m_zConstants.w;
  55. }
  56. // Light visibility grid is this wide
  57. // e.g. if the screen resolution is 1904 x 800 with 16x16 bins then grid width is 1904/16 = 119
  58. uint m_tileGridWidth;
  59. // Point lights
  60. struct PointLight
  61. {
  62. float3 m_position;
  63. float m_invAttenuationRadiusSquared; // For a radius at which this light no longer has an effect, 1 / radius^2.
  64. float3 m_rgbIntensity;
  65. float m_bulbRadius;
  66. };
  67. StructuredBuffer<PointLight> m_pointLights;
  68. uint m_pointLightCount;
  69. }
  70. float4 main() : SV_Target0
  71. {}