Files
Steve Pham 38261d0800 Shorten copyright headers by splitting into 2 lines (#2213)
* Updated all copyright headers to split the longer original copyright line into 2 shorter lines

Signed-off-by: Steve Pham <spham@amazon.com>
2021-07-16 15:25:48 -07:00

75 lines
1.9 KiB
Plaintext

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Atom/Features/SrgSemantics.azsli>
struct VertexInput
{
float2 Position : POSITION;
float2 UV : UV;
float4 Color : COLOR;
};
struct VertexOutput
{
float4 Position : SV_Position;
float4 Color : COLOR;
float2 UV : UV;
};
ShaderResourceGroup ObjectSrg : SRG_PerObject
{
Texture2D<float4> FontImage;
Sampler LinearSampler
{
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
AddressW = Clamp;
};
column_major float4x4 m_projectionMatrix;
}
float3 SRGBToLinear( float3 x )
{
return x < 0.04045f ? x / 12.92f : pow( (abs(x) + 0.055f) / 1.055f, 2.4f );
// NOTE: abs on x quiets FXC warning "X3571: pow(f, e) will not work for negative f,
// use abs(f) or conditionally handle negative values if you expect them".
// Ternary operator ?: in shaders can handle vectors in the condition, but it doesn't
// count as 'conditionally handle' since branching is not involved. When we start using
// DXC instead of FXC we can remove abs since DXC handles it correctly with no warnings.
}
VertexOutput MainVS(in VertexInput input)
{
VertexOutput output;
output.Position = mul(float4(input.Position, 0.0f, 1.0f), ObjectSrg::m_projectionMatrix);
output.Color = float4(SRGBToLinear(input.Color.rgb), input.Color.a);
output.UV = input.UV;
return output;
}
struct PixelOutput
{
float4 m_color : SV_Target0;
};
PixelOutput MainPS(in VertexOutput input)
{
PixelOutput output;
float4 color = ObjectSrg::FontImage.Sample(ObjectSrg::LinearSampler, input.UV) * input.Color;
output.m_color = float4(color.rgb * color.a, color.a);
return output;
}