// 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.
/// <summary>
/// Base shader to perfom shading. Defines the basic method and inserts it in the pipeline.
/// </summary>
/// <remarks>
/// STRIDE_RENDER_TARGET_COUNT: Macro - Number of render targets.
/// </remarks>

#ifndef STRIDE_RENDER_TARGET_COUNT
# define STRIDE_RENDER_TARGET_COUNT 1
#endif

shader ShadingBase : ShaderBase
{
    compose ComputeColor ShadingColor0;

#if STRIDE_RENDER_TARGET_COUNT > 1
    compose ComputeColor ShadingColor1;
#endif
#if STRIDE_RENDER_TARGET_COUNT > 2
    compose ComputeColor ShadingColor2;
#endif
#if STRIDE_RENDER_TARGET_COUNT > 3
    compose ComputeColor ShadingColor3;
#endif
#if STRIDE_RENDER_TARGET_COUNT > 4
    compose ComputeColor ShadingColor4;
#endif
#if STRIDE_RENDER_TARGET_COUNT > 5
    compose ComputeColor ShadingColor5;
#endif
#if STRIDE_RENDER_TARGET_COUNT > 6
    compose ComputeColor ShadingColor6;
#endif
#if STRIDE_RENDER_TARGET_COUNT > 7
    compose ComputeColor ShadingColor7;
#endif

    // method computing color
    stage float4 Shading()
    {
        return ShadingColor0.Compute();
    }
    
    stage override void PSMain()
    {
        base.PSMain();
        streams.ColorTarget = this.Shading();

#if STRIDE_RENDER_TARGET_COUNT > 1
        streams.ColorTarget1 = ShadingColor1.Compute();
#endif
#if STRIDE_RENDER_TARGET_COUNT > 2
        streams.ColorTarget2 = ShadingColor2.Compute();
#endif
#if STRIDE_RENDER_TARGET_COUNT > 3
        streams.ColorTarget3 = ShadingColor3.Compute();
#endif
#if STRIDE_RENDER_TARGET_COUNT > 4
        streams.ColorTarget4 = ShadingColor4.Compute();
#endif
#if STRIDE_RENDER_TARGET_COUNT > 5
        streams.ColorTarget5 = ShadingColor5.Compute();
#endif
#if STRIDE_RENDER_TARGET_COUNT > 6
        streams.ColorTarget6 = ShadingColor6.Compute();
#endif
#if STRIDE_RENDER_TARGET_COUNT > 7
        streams.ColorTarget7 = ShadingColor7.Compute();
#endif
    }
};
