// 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.Images
{
    /// <summary>
    /// A utility shader for luminance.
    /// </summary>
    shader LuminanceUtils
    {
        /// <summary>
        /// Calculate the perceptive luminance (601Y')
        /// </summary>
        /// <remarks>
        /// http://en.wikipedia.org/wiki/HSL_and_HSV#Lightness
        /// http://www.poynton.com/PDFs/YUV_and_luminance_harmful.pdf
        /// </remarks>
        static float Luma(float3 color)
        {
            return max(dot(color, float3(0.299, 0.587, 0.114)), 0.0001);
        }
    };
}
