Thanks for the reply.
I’ve investigated the issue further and, while from my initial tests i thought it was related to RGB textures only, i noticed the same behavior also on RGBA (but still only on alpha channel…). So, my initial assumption was wrong.
This is the glitched version
#ifdef DIFFUSEMAPA
uniform sampler2D m_DiffuseMapA;
#endif
#ifdef DIFFUSEMAPB
uniform sampler2D m_DiffuseMapB;
#endif
flat in int type;
void main(){
float alpha=0.;
if(type==0){
#ifdef DIFFUSEMAPA
vec4 diffuseColor=texture(m_DiffuseMapA,texCoord);
alpha = diffuseColor.a;
#endif
}else{
#ifdef DIFFUSEMAPB
vec4 diffuseColor=texture(m_DiffuseMapB,texCoord);
alpha = diffuseColor.a;
#endif
}
if(alpha<.9)discard;
outFragColor=vec4(0,0,0,1);
}
I’ve found that if i replace texture() with this
vec4 ___texture(in sampler2D tx,in vec2 coord){
vec4 c=texture(tx,coord);
c.a=max(c.a,c.a); // Works also with some other functions, like min and abs, doesn't work with clamp...
return c;
}
the glitches disappear… But this is not a good solution, so i tried to mess around with the code and i’ve found out that this version doesn’t cause the glitch
#ifdef DIFFUSEMAPA
uniform sampler2D m_DiffuseMapA;
#endif
#ifdef DIFFUSEMAPB
uniform sampler2D m_DiffuseMapB;
#endif
flat in int type;
void main(){
float alpha=0.;
if(type==0){
#ifdef DIFFUSEMAPA
vec4 diffuseColor=texture(m_DiffuseMapA,texCoord);
alpha = diffuseColor.a;
if(alpha<.9)discard; // <<<<<<<<<<<<<<<<<<<<
#endif
}else{
#ifdef DIFFUSEMAPB
vec4 diffuseColor=texture(m_DiffuseMapB,texCoord);
alpha = diffuseColor.a;
if(alpha<.9)discard; // <<<<<<<<<<<<<<<<<<<<<
#endif
}
// if(alpha<.9)discard;
outFragColor=vec4(0,0,0,1);
}
I’m clueless on why. If leave the code as it is but i comment out the two discard lines and i leave only the bottom one, the glitches come back… probably it has something to do with the optimizations made by the mesa compiler…