/*
 * Copyright (c) Contributors to the Open 3D Engine Project.
 * For complete copyright and license terms please see the LICENSE at the root of this distribution.
 *
 * SPDX-License-Identifier: Apache-2.0 OR MIT
 *
 */

#include <Atom/Features/SrgSemantics.azsli>
#include "RayTracingCommon.azsli"

// hit shader that uses the ray's intersection point on the triangle to modulate an output color
[shader("closesthit")] 
void ClosestHitGradientShader(inout RayPayload payload, BuiltInTriangleIntersectionAttributes attr) 
{
    float3 barycentrics = float3(1 - attr.barycentrics.x - attr.barycentrics.y, attr.barycentrics.x, attr.barycentrics.y);
    payload.color = float4(barycentrics, 1.0f) * RayTracingGlobalSrg::m_hitGradientData[InstanceID()].m_color;   
}