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