// 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>
/// Calculates the normal  the normals from a normal map.
/// </summary>
shader NormalFromNormalMapping : Transformation, NormalBase, NormalStream
{
    override stage void GenerateNormal_PS()
    {
        base.GenerateNormal_PS();
        UpdateTangentToWorld();
        // Transform meshNormal from object space to world space:
        streams.meshNormalWS = mul(streams.meshNormal, (float3x3)WorldInverseTranspose);    // TODO: PERFORMANCE: Normalization required?
    }

    override float3x3 GetTangentWorldTransform()
    {
        return (float3x3)WorldInverseTranspose;
    }
};
