// 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.
shader ComputeColorOverlay : ComputeColor
{
    compose ComputeColor color1;
    compose ComputeColor color2;

    override float4 Compute()
    {
        float4 tex1 = color1.Compute();
        float4 tex2 = color2.Compute();

        // http://en.wikipedia.org/wiki/Blend_modes#Overlay
        // if a < 0.5f: 2ab
        // if a >= 0.5f: 1 - 2(1 - a)(1 - b)
        return lerp(2.0f * tex1 * tex2,
                1.0f - 2.0f * (1.0f - tex1) * (1.0f - tex2),
                step(tex2, 0.5));
    }
};
