#version 150 in vec2 vertTexCoord; in vec4 vertColor; in float vertTextureIndex; uniform sampler2D sdfTextures[8]; uniform float threshold; uniform float smoothRange; out vec4 fragColor; void main() { float smoothMin = threshold - smoothRange * 0.5; float smoothMax = smoothMin + smoothRange; float sample = 0.0; sample += smoothstep(smoothMin, smoothMax, texture(sdfTextures[0], vertTexCoord).r) * int(vertTextureIndex == 0); sample += smoothstep(smoothMin, smoothMax, texture(sdfTextures[1], vertTexCoord).r) * int(vertTextureIndex == 1); sample += smoothstep(smoothMin, smoothMax, texture(sdfTextures[2], vertTexCoord).r) * int(vertTextureIndex == 2); sample += smoothstep(smoothMin, smoothMax, texture(sdfTextures[3], vertTexCoord).r) * int(vertTextureIndex == 3); sample += smoothstep(smoothMin, smoothMax, texture(sdfTextures[4], vertTexCoord).r) * int(vertTextureIndex == 4); sample += smoothstep(smoothMin, smoothMax, texture(sdfTextures[5], vertTexCoord).r) * int(vertTextureIndex == 5); sample += smoothstep(smoothMin, smoothMax, texture(sdfTextures[6], vertTexCoord).r) * int(vertTextureIndex == 6); sample += smoothstep(smoothMin, smoothMax, texture(sdfTextures[7], vertTexCoord).r) * int(vertTextureIndex == 7); fragColor = vec4(min(1.0, sample)) * vertColor; }