title: Fragment Shader Rotation
body: <p>I've been having a few problems with my fragment shader. After a bit of research, it appears that drivers clean up unused variables (ones which have no effect on the output?), which can cause glSetUniform and glGetUniform to return -1. </p>
  
  <p>My current problem is that I'm attempting to rotate a texture 180 degrees, but it appears that I'm doing something incorrectly, as the uniform int "top" appears to be garbage collected, and cannot be found. The texture is not rotated at all, but still renders. The uniform "top" returns -1, which should not happen.</p>
  
  <p>Here's my relevant code:</p>
  
  <p>Rendering and Shader Enable code: (Shader.PIPE.enable() does call glUseProgram())</p>
  
  <pre><code>    Shader.PIPE.enable();
      Shader.PIPE.setUniformMat4f("vw_matrix", Matrix4f.translate(new Vector3f(xScroll * 0.03f, 0.0f, 0.0f)));    
      Pipe.getTexture().bind();
      Pipe.getMesh().bind();
  
      for (int i = 0; i &lt; 5 * 2; i++) {
          Shader.PIPE.setUniformMat4f("ml_matrix", pipes[i].getModelMatrix());
          Shader.PIPE.setUniform1i("top",  i % 2 == 0 ? 1 : 0);
          Pipe.getMesh().draw();
      }
      Pipe.getMesh().unbind();
      Pipe.getTexture().unBind();
  </code></pre>
  
  <p>Pipe.frag:</p>
  
  <pre><code>#version 330 core
  
  layout (location = 0) out vec4 color;
  
  in DATA 
  {
      vec2 tc;
  } fs_in;
  
  uniform sampler2D tex;
  uniform int top;
  
  void main() 
  {   
      vec2 myTc = vec2(fs_in.tc.x, fs_in.tc.y);
      if (top == 1) {
          myTc.y = top - myTc.y;  
      }
  
      color = texture(tex, fs_in.tc);
      if (color.w  &lt; 1.0)
          discard;
  }
  </code></pre>
  
  <p>Pipe.vert:</p>
  
  <pre><code>#version 330 core
  
  layout (location = 0) in vec4 position;
  layout (location = 1) in vec2 tc;
  
  uniform mat4 pr_matrix;
  uniform mat4 vw_matrix = mat4(1.0);
  uniform mat4 ml_matrix = mat4(1.0);
  
  out DATA
  {
      vec2 tc;
  } vs_out;
  
  void main() 
  {
      gl_Position = pr_matrix * vw_matrix * ml_matrix * position;
      vs_out.tc = tc;
  }
  </code></pre>