61 lines
1.1 KiB
GLSL
61 lines
1.1 KiB
GLSL
/**
|
|
* QUIK: User Interface Kit
|
|
* Copyright (C) 2023 Halit Utku Maden, et al.
|
|
*/
|
|
#version 130
|
|
|
|
in vec2 fv2TexPos;
|
|
in vec4 fv4Color;
|
|
in float ffTexLayer;
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
void main(void)
|
|
{
|
|
vec4 albedo = fv4Color;
|
|
|
|
if (iEnableTexture != 0)
|
|
{
|
|
vec4 value = getTexture();
|
|
|
|
if (iEnableSdf != 0)
|
|
{
|
|
float a = max(value.r, value.a);
|
|
|
|
value =
|
|
(a >= fSdfThreshold) ?
|
|
vec4(1.0,1.0,1.0,1.0) :
|
|
vec4(0.0,0.0,0.0,0.0);
|
|
}
|
|
|
|
if (iAlphaDiscard != 0 && value.a <= fAlphaThreshold)
|
|
{
|
|
discard;
|
|
}
|
|
|
|
albedo = albedo * value;
|
|
}
|
|
|
|
fragColor = albedo;
|
|
} |