RayTracingClosestHitGradient.azsl 763 B

123456789101112131415161718
  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. #include "RayTracingCommon.azsli"
  10. // hit shader that uses the ray's intersection point on the triangle to modulate an output color
  11. [shader("closesthit")]
  12. void ClosestHitGradientShader(inout RayPayload payload, BuiltInTriangleIntersectionAttributes attr)
  13. {
  14. float3 barycentrics = float3(1 - attr.barycentrics.x - attr.barycentrics.y, attr.barycentrics.x, attr.barycentrics.y);
  15. payload.color = float4(barycentrics, 1.0f) * RayTracingGlobalSrg::m_hitGradientData[InstanceID()].m_color;
  16. }