// 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>
    /// The logarithmic tonemap operator.
    /// </summary>
    internal shader ToneMapLogarithmicOperatorShader : ToneMapCommonOperatorShader
    {
        override float4 Compute(float4 color)
        {
	        float pixelLuminance = LuminanceUtils.Luma(color);    
	        float toneMappedLuminance = log10(1 + pixelLuminance) / log10(1 + WhiteLevel);
	        return toneMappedLuminance * pow(color / pixelLuminance, LuminanceSaturation); 
        }
    };
}
