RayGen.hlsl 846 B

1234567891011121314151617181920212223242526
  1. #include "Common.hlsl"
  2. // Raytracing output texture, accessed as a UAV
  3. RWTexture2D<float4> gOutput : register(u0);
  4. RWTexture2D<float4> guiTexture : register(u1);
  5. // Raytracing acceleration structure, accessed as a SRV
  6. RaytracingAccelerationStructure SceneBVH : register(t0);
  7. [shader("raygeneration")]
  8. void RayGen()
  9. {
  10. // Initialize the ray payload
  11. HitInfo payload;
  12. payload.colorAndDistance = float4(0.9, 0.6, 0.2, 1.0);
  13. // Get the location within the dispatched 2D grid of work items
  14. // (often maps to pixels, so this could represent a pixel coordinate).
  15. uint2 launchIndex = DispatchRaysIndex().xy;
  16. float4 guiColor = guiTexture[launchIndex];
  17. gOutput[launchIndex] = float4(payload.colorAndDistance.rgb * (1 - guiColor.a) + guiColor.rgb * guiColor.a, 1.f);
  18. gOutput[launchIndex] = float4(1.0, 1.0, 1.0, 1.0);
  19. }