// 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
{
    /// <summary>
    /// A shader used to output the id of the model component, mesh and material for a particular RenderMesh
    /// </summary>
    shader PickingShader : ShaderBase
    {
        cbuffer PerDraw
        {
            stage float4 PickingData;
        }

        stage override void PSMain()
        {
            float modelComponentId = PickingData.x + (min(streams.InstanceID, 1023.0) / 1024.0);
            float meshMaterialIndex = PickingData.y;
            streams.ColorTarget = float4(modelComponentId, meshMaterialIndex, 1, 1);
        }
    };
}
