0 Replies Latest reply on Nov 3, 2015 1:56 PM by octo

    GLSL fragment discarded on AMD when unused texture lookup is present

    octo

      Hi,

       

      I am doing a texture lookup to color a surface in a GLSL fragment shader. Under a specific case, the texture coordinate must be fetched from an additional texture, which will be loaded only in this case.

       

      This works fine on Nvidia and Intel graphic cards but not on AMD. With AMD the fragment is discarded if the 2nd texture is not loaded. No matter the result of the if statement.

       

      What is proper way to implement this in the fragment shader to avoid this issue?

       

      Thank you for your help.

       

       

      #version 120

      uniform sampler3D colorMap
      ;
      uniform sampler1D zTexture
      ;
      uniform
      bool useZtexture;

      void main(void)
      {
        
      float zTexCoord = 0.0f;

        
      if(useZtexture == true)
        
      {
            
      // unitialized zTexture causes the fragment to be discarded
            
      // even when useZtexture is false
             zTexCoord
      = float(texture1D(zTexture, 0.0f));
        
      }

         gl_FragColor
      = texture3D( colorMap, vec3(gl_TexCoord[0].s, gl_TexCoord[0].t, zTexCoord));
      }