// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
namespace Stride.Rendering.Lights
{
    /// <summary>
    /// Computes the texture projection of a spotlight. Returns the color of the projected texture at this world space position.
    /// </summary>
    /// <remarks>
    /// PerLightGroup: Parameter used to uniquely identify this group of lights.
    /// TLightCount: The number of lights inside of this light group.
    /// </remarks>
    internal shader TextureProjectionReceiverSpot<MemberName PerLightGroup, int TLightCount, int TFlipMode> :
        TextureProjectionGroup, // Defines "ComputeTextureProjection()", which this shader overrides.
        TextureProjectionReceiverBase<PerLightGroup, 1, TLightCount, TFlipMode>    // Defines "CalculateTextureProjectionFromCascade()".
    {
        override float3 ComputeTextureProjection(float3 positionWS, int lightIndex)
        {
            return ComputeTextureProjectionFromCascade(positionWS, 0, lightIndex);  // Spotlights have only one cascade, so we hardcode the cascade index to zero.
        }

        override float3 ComputeSpecularTextureProjection(float3 positionWS, float3 reflectionWS, int lightIndex)
        {
            return ComputeSpecularTextureProjectionFromCascade(positionWS, reflectionWS, 0, lightIndex);  // Spotlights have only one cascade, so we hardcode the cascade index to zero.
        }
    };
}
