/*
 * 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>

ShaderResourceGroup PassSrg : SRG_PerPass
{
    column_major float4x4 m_objectMatrix;
}

struct VSInput
{
    uint m_vertexID : SV_VertexID;
};

struct VSOutput
{
    float4 m_position : SV_Position;
    float4 m_color : COLOR0;
};

VSOutput MainVS(VSInput vsInput)
{
    VSOutput OUT;

    switch(vsInput.m_vertexID)
    {
    case 0:
        OUT.m_position = float4(0.0,  0.5, 0.0, 1.0);
        OUT.m_color = float4(1.0, 0.0, 0.0, 1.0);
        break;
    case 1:
        OUT.m_position = float4(-0.5, -0.5, 0.0, 1.0);
        OUT.m_color = float4(0.0, 1.0, 0.0, 1.0);
        break;
    default:
        OUT.m_position = float4(0.5, -0.5, 0.0, 1.0);
        OUT.m_color = float4(0.0, 0.0, 1.0, 1.0);
        break;
    }

    OUT.m_position = mul(PassSrg::m_objectMatrix, OUT.m_position);

    return OUT;
}

struct PSOutput
{
    float4 m_color : SV_Target0;
};

PSOutput MainPS(VSOutput vsOutput)
{
    PSOutput OUT;

    OUT.m_color = vsOutput.m_color;

    // Simple tonemapping:
    OUT.m_color.rgb = pow(OUT.m_color.rgb, 1.0/2.2);
    return OUT;
}
