Dashboard/Quik.OpenTK/glsl/glsl130.frag
H. Utku Maden 9339295378 Push all uncommitted changes.
I have had a long break from this project due to other higher priority
things going on in my life. Big changes inbound.
2023-05-13 16:17:57 +03:00

62 lines
1.3 KiB
GLSL

#version 130
#define F_TEXTURE (1 << 0)
#define F_DISCARD_EN (1 << 1)
#define F_SDF (1 << 2)
#define F_SDF_AUX_EN (1 << 3)
uniform int iFlags;
uniform float fSdfThreshold;
uniform float fSdfAuxilliaryThreshold;
uniform vec4 v4SdfAuxilliaryColor;
uniform sampler2D x2Texture;
uniform vec2 v2TextureOffset;
in vec2 fv2Texture;
out vec4 fv4Color;
vec4 v4Color()
{
vec4 color = fv4Color;
if ((iFlags & F_TEXTURE) != 0)
{
if ((iFlags & F_SDF) != 0)
{
float a = texture(x2Texture, fv2Texture + v2TextureOffset).a;
if ((iFlags & F_SDF_AUX_EN) != 0)
{
color =
(a > fSdfThreshold)
? color
: (a > fSdfAuxilliaryThreshold)
? v4SdfAuxilliaryColor
: vec4(0, 0, 0, 0);
}
else if (a < fSdfThreshold)
{
color = vec4(0, 0, 0, 0);
}
}
else
{
color *= texture(x2Texture, fv2Texture + v2TextureOffset);
}
}
return color;
}
void main()
{
vec4 color = v4Color();
if ((iFlags & F_DISCARD_EN) != 0 && color.a <= 0)
{
discard;
}
fv4Color = color;
}