AronaSlate/Content/Shader/StandaloneRenderer/OpenGL/SlateDefaultVertexShader.glsl
2024-01-25 11:21:15 +08:00

51 lines
1.1 KiB
GLSL

// Copyright Epic Games, Inc. All Rights Reserved.
// #version 120 at the beginning is added in FSlateOpenGLShader::CompileShader()
uniform mat4 ViewProjectionMatrix;
// Per vertex
in vec4 InTexCoords;
in vec2 InPosition;
in vec4 InColor;
in vec4 InSecondaryColor;
// Between vertex and pixel shader
out vec4 Position;
out vec4 TexCoords;
out vec4 Color;
out vec4 SecondaryColor;
vec3 powScalar(vec3 values, float power)
{
return vec3(pow(values.x, power), pow(values.y, power), pow(values.z, power));
}
float sRGBToLinearChannel( float ColorChannel )
{
return ColorChannel > 0.04045 ? pow( ColorChannel * (1.0 / 1.055) + 0.0521327, 2.4 ) : ColorChannel * (1.0 / 12.92);
}
vec3 sRGBToLinear( vec3 Color )
{
return vec3(
sRGBToLinearChannel(Color.r),
sRGBToLinearChannel(Color.g),
sRGBToLinearChannel(Color.b));
}
void main()
{
TexCoords = InTexCoords;
Color.rgb = sRGBToLinear(InColor.rgb);
Color.a = InColor.a;
SecondaryColor.rgb = sRGBToLinear(InSecondaryColor.rgb);
SecondaryColor.a = InSecondaryColor.a;
Position = vec4( InPosition, 0, 1 );
gl_Position = ViewProjectionMatrix * vec4( InPosition, 0, 1 );
}