Common.hlsl 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Hit information, aka ray payload
  2. // This sample only carries a shading color and hit distance.
  3. // Note that the payload should be kept as small as possible,
  4. // and that its size must be declared in the corresponding
  5. // D3D12_RAYTRACING_SHADER_CONFIG pipeline subobjet.
  6. #pragma pack_matrix(row_major)
  7. #define MAX_TRANSPACENT_HITS 5
  8. struct [raypayload] HitInfo
  9. {
  10. float4 color[MAX_TRANSPACENT_HITS] : write(caller, closesthit, anyhit, miss) : read(caller, anyhit, closesthit, miss);
  11. float distance[MAX_TRANSPACENT_HITS] : write(caller, closesthit, anyhit) : read(caller, anyhit, closesthit);
  12. uint hitCount : write(caller, anyhit, closesthit, miss) : read(caller, anyhit, closesthit, miss);
  13. };
  14. // Attributes output by the raytracing when hitting a surface,
  15. // here the barycentric coordinates
  16. struct Attributes
  17. {
  18. float2 bary;
  19. };
  20. // global root signature resources
  21. Texture2D<float4> textures[] : register(t0, space1);
  22. SamplerState gSampler : register(s0, space0);
  23. // Raytracing output texture, accessed as a UAV
  24. RWTexture2D<float4> gOutput : register(u0);
  25. RWTexture2D<float4> guiTexture : register(u1);
  26. // Raytracing acceleration structure, accessed as a SRV
  27. RaytracingAccelerationStructure TLAS : register(t0, space0);
  28. cbuffer RayGenerationSettings : register(b0)
  29. {
  30. int renderGui;
  31. int useRays;
  32. float minDistance;
  33. float maxDistance;
  34. float4x4 inverseView;
  35. float4x4 inverseProjection;
  36. }