/*
 * 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 <scenesrg.srgi>
#include <viewsrg.srgi>
#include <Atom/Features/PBR/DefaultObjectSrg.azsli>

struct VertexInput
{
    float3 m_position : POSITION;
    float3 m_normal : NORMAL;
};

struct VertexOutput
{
    float4 m_position : SV_Position;
    float3 m_normal : NORMAL;
};

VertexOutput MainVS(VertexInput input)
{
    const float4x4 objectToWorldMatrix = ObjectSrg::GetWorldMatrix();

    VertexOutput output;
    float4 worldPosition = mul(objectToWorldMatrix, float4(input.m_position, 1.0));
    output.m_position = mul(ViewSrg::m_viewProjectionMatrix, worldPosition);
    
    float3x3 objectToWorldMatrixIT = ObjectSrg::GetWorldMatrixInverseTranspose();
    output.m_normal = mul(objectToWorldMatrixIT, input.m_normal);
    output.m_normal = normalize(output.m_normal);
    return output;
}

struct PixelOutput
{
    float4 m_color : SV_Target0;
};

PixelOutput MainPS(VertexOutput input)
{
    PixelOutput output;

    output.m_color.rgb = normalize(input.m_normal) * 0.5 + 0.5;
	output.m_color.a = 1.0;

    return output;
} 