title: Fragment shader and coloring a texture
body: <p>I'm trying to make sense of adjusting texture colors with a fragment shader. My fragment shader is super simple:</p>
  
  <pre><code>uniform sampler2D sampler;
  
  void main() {
    vec4 tex = texture2D ( sampler, uvVarying );
    gl_FragColor = vec4(tex.r, tex.g, tex.b, tex.a);
  }
  </code></pre>
  
  <p>This draws my dog texture as expected:
  <img src="https://i.stack.imgur.com/USMlu.png" alt="normal dog"></p>
  
  <p>if I then change the shader to</p>
  
  <pre><code>  gl_FragColor = vec4(tex.r, tex.g, tex.b, 1.0);
  </code></pre>
  
  <p>the result is what I expected, transparency info is lost:</p>
  
  <p><img src="https://i.stack.imgur.com/HSWJW.png" alt="no transparency"></p>
  
  <p>but if I instead set it to:</p>
  
  <pre><code>  gl_FragColor = vec4(tex.r, tex.g, tex.b, 0.0);
  </code></pre>
  
  <p>I was expecting it to disappear completely, but instead I get:</p>
  
  <p><img src="https://i.stack.imgur.com/uKsqd.png" alt="green dog"></p>
  
  <p>What is going on??</p>
  
  <p>And to my original problem: I wanted to add a little red tint to my texture with:</p>
  
  <pre><code>  gl_FragColor = vec4(tex.r + 0.5, tex.g, tex.b, tex.a);
  </code></pre>
  
  <p>Now, I was expecting it to have same transparency info as the original texture, but instead I get this:</p>
  
  <p><img src="https://i.stack.imgur.com/PK84H.png" alt="red dog"></p>
  
  <p>What am I missing here. The texture is using default blending of the engine which is <code>src = GL_ONE, dst = GL_ONE_MINUS_SRC_ALPHA</code>.</p>