I have a fairly basic fragment shader which can sample from texture and change the assigned fixed color based on the sample. If I sample from the texture, I do an alpha check and discard low-alpha values. Is there a way to make this process branchless?
#version 460 core
layout (location = 0) out vec4 FragColor;
uniform vec4 color;
uniform sampler2D tex;
uniform bool useTex;
in vec2 texCoords;
void main() {
vec4 tex = texture(tex, texCoords);
if(useTex && tex.a < 0.1) { discard; }
vec4 outColor = mix(color, color * tex, int(useTex));
FragColor = outColor;
}