Dashboard/Quik/res/gl21.frag

61 lines
1.1 KiB
GLSL
Raw Normal View History

2023-06-30 18:35:24 +02:00
/**
* QUIK: User Interface Kit
* Copyright (C) 2023 Halit Utku Maden, et al.
*/
2024-04-14 21:51:10 +02:00
#version 130
2023-06-30 18:35:24 +02:00
2024-04-14 21:51:10 +02:00
in vec2 fv2TexPos;
in vec4 fv4Color;
in float ffTexLayer;
2023-06-30 18:35:24 +02:00
2024-04-14 21:51:10 +02:00
out vec4 fragColor;
uniform int iEnableSdf;
uniform int iEnableTexture;
uniform int iAlphaDiscard;
uniform float fSdfThreshold;
uniform sampler2D tx2d;
uniform sampler2DArray tx2dArray;
const float fAlphaThreshold = 0.01;
vec4 getTexture()
{
if (iEnableTexture == 3)
{
return texture(tx2dArray, vec3(fv2TexPos, ffTexLayer));
}
else
{
return texture(tx2d, fv2TexPos);
}
}
2023-06-30 18:35:24 +02:00
void main(void)
{
vec4 albedo = fv4Color;
if (iEnableTexture != 0)
{
2024-04-14 21:51:10 +02:00
vec4 value = getTexture();
2023-06-30 18:35:24 +02:00
if (iEnableSdf != 0)
{
float a = max(value.r, value.a);
2024-04-14 21:51:10 +02:00
value =
(a >= fSdfThreshold) ?
vec4(1.0,1.0,1.0,1.0) :
vec4(0.0,0.0,0.0,0.0);
2023-06-30 18:35:24 +02:00
}
2024-04-14 21:51:10 +02:00
if (iAlphaDiscard != 0 && value.a <= fAlphaThreshold)
2023-06-30 18:35:24 +02:00
{
discard;
}
albedo = albedo * value;
}
2024-04-14 21:51:10 +02:00
fragColor = albedo;
2023-06-30 18:35:24 +02:00
}