25 lines
573 B
GLSL
25 lines
573 B
GLSL
#version 450
|
|
|
|
layout(location = 0) in vec4 color;
|
|
layout(location = 1) in vec4 bgColor;
|
|
layout(location = 2) in vec2 texCoord;
|
|
|
|
layout(location = 0) out vec4 outColor;
|
|
|
|
layout(set = 2, binding = 0) uniform sampler2D texSampler;
|
|
|
|
const float threshold = 0.4f;
|
|
const float smoothing = 1.f/32.f;
|
|
|
|
void main()
|
|
{
|
|
float distance = texture(texSampler, texCoord).r;
|
|
float alpha = smoothstep(threshold - smoothing, threshold + smoothing, distance);
|
|
outColor = vec4(color) * alpha;
|
|
|
|
if (bgColor.a != 0)
|
|
{
|
|
outColor = mix(bgColor, outColor, alpha);
|
|
}
|
|
}
|