Dear OpenGL community,
I am new in the openGL development world and I am facing some inexplicable ( for me ) issues.
We have shader :
void main()
{
if ( discarded == 1 )
discard;
const float reflectFactor = 0.5;
vec4 fragmentColor;
if ( clippingPlaneCount==2 && (clippingPlane1.x>outposition.x || clippingPlane1.y>outposition.y || clippingPlane2.x<outposition.x || clippingPlane2.y<outposition.y) )
discard;
if ( activeCuttingPlane == 1 && isCuttedByPlane() > 0.5 )
discard;
adaptedNormal = outnormal;
//if ( dot (gl_Normal,outnormal) <0.0 ) adaptedNormal = vec3(-outnormal.x,-outnormal.y,-outnormal.z);
if ( meridionalView == 0.0 )
{
// Reverse normal if back facing
if ( !gl_FrontFacing )
adaptedNormal = -outnormal;
}
...
}
We noticed that when using Mesa we get some “black” surface in the back of the geometry.
We found that the reason was :
// Reverse normal if back facing
if ( !gl_FrontFacing )
adaptedNormal = -outnormal;
Here if we change to :
// Reverse normal if back facing
if ( gl_FrontFacing == false )
adaptedNormal = -outnormal;
I work fine.
Can you tell me why the if statement with ! , where gl_FrontFacing is a bool is not interpreted as in C ?
It might be a noob question but I developed in C, java and C++ and for me this should be ok …
Note : This code work well on native openGL machine. Mesa is used on remote desktop or when the machine doesn’t support OpenGL 2.1 or higher.
Regards