// 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>
/// Declares and sets the value of the screen position of the fragment ({x,y} in [-1,1], z in [0,1]).
/// Be careful when to include this shader because ShadingPosition should be correct at this point. Include this shader at the end of the mixin list.
/// </summary>
shader ScreenPositionBase : ShaderBase
{
    // The position in screen space
    stage stream float4 ScreenPosition;

    stage override void VSMain()
    {
        base.VSMain();
        streams.ScreenPosition = streams.ShadingPosition;
    }

    stage override void PSMain()
    {
        streams.ScreenPosition /= streams.ScreenPosition.w;
        base.PSMain();
    }
};
