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

ShaderResourceGroupSemantic SRG_PerView
{
    FrequencyId = 4;
};

ShaderResourceGroup ViewSrg : SRG_PerView
{
    row_major float4x4 m_viewProjectionMatrix;
    row_major float4x4 m_viewMatrix;
    row_major float4x4 m_projectionMatrix;

    float3 m_worldPosition;

    // precached depth constants for faster evaluation
    // x -> NearZ
    // y -> FarZ
    // z -> FarZ * NearZ
    // w -> FarZ - NearZ
    float4 m_zConstants;

    float3 GetWorldPosition()
    {
        return m_worldPosition;
    }

    float4x4 GetViewProjectionMatrix()
    {
        return m_viewProjectionMatrix;
    }

    float4x4 GetViewMatrix()
    {
        return m_viewMatrix;
    }

    float4x4 GetProjectionMatrix()
    {
        return m_projectionMatrix;
    }

    float GetNearZ()
    {
        return m_zConstants.x;
    }

    float GetFarZ()
    {
        return m_zConstants.y;
    }

    float GetFarZTimesNearZ()
    {
        return m_zConstants.z;
    }

    float GetFarZMinusNearZ()
    {
        return m_zConstants.w;
    }

     // Light visibility grid is this wide
    // e.g. if the screen resolution is 1904 x 800 with 16x16 bins then grid width is 1904/16 = 119
    uint m_tileGridWidth;

    // Point lights

    struct PointLight
    {
        float3 m_position;
        float m_invAttenuationRadiusSquared; // For a radius at which this light no longer has an effect, 1 / radius^2.
        float3 m_rgbIntensity;
        float m_bulbRadius;
    };

    StructuredBuffer<PointLight> m_pointLights;
    uint m_pointLightCount;
}

float4 main() : SV_Target0
{}