title: Custom shader results in black screen on Android
body: <p>I'm trying to use custom shaders for a libgdx project to run on Android. I have not figured out how to USB debug, so I can't seem to get any logs when running on a real Android device.</p>
  
  <p>The problem is that implementing the shader I wrote results in a black screen on my Samsung Galaxy Nexus. It produces the correct results in the desktop project AND the Android project run on an Android emulator in Eclipse. Not implementing the shader makes it also render right on my Android (albeit without the shader effect).</p>
  
  <p>So I'm presenting the issue hoping someone else can spot any problem(s). Best regards.</p>
  
  <p>The shader setup (in Java):</p>
  
  <pre><code>ShaderProgram.pedantic = false;
  shader = new ShaderProgram(
      Gdx.files.internal("shaders/vignette.vsh"),
      Gdx.files.internal("shaders/vignette.fsh"));
  
  if (! shader.isCompiled()) {
      Gdx.app.log("Shader", shader.getLog());
  }
  
  renderer.getSpriteBatch().setShader(shader);
  
  glow.batch.setShader(shader);
  
  shader.begin();
  shader.setUniformf("u_near", .2f);
  shader.setUniformf("u_dim", .85f);
  shader.end();
  </code></pre>
  
  <p>The vertex shader:</p>
  
  <pre><code>precision mediump float;
  
  attribute vec4 a_color;
  attribute vec3 a_position;
  attribute vec2 a_texCoord0;
  
  uniform mat4 u_projTrans;
  
  varying vec4 v_color;
  varying vec2 v_texCoord0;
  
  void main() {
      v_color = a_color;
      v_texCoord0 = a_texCoord0;
      gl_Position = u_projTrans * vec4(a_position, 1.0);
  }
  </code></pre>
  
  <p>Fragment shader:</p>
  
  <pre><code>precision mediump float;
  
  varying vec4 v_color;
  varying vec2 v_texCoord0;
  
  uniform vec2 u_lightPos;
  uniform float u_radius;
  uniform float u_near;
  uniform float u_dim;
  uniform sampler2D u_sampler2D;
  
  void main() {
      vec4 color = texture2D(u_sampler2D, v_texCoord0) * v_color;
  
      vec2 relativePosition = (u_lightPos - gl_FragCoord.xy) / u_radius;
      float len = length(relativePosition);
      float vignette = smoothstep(.5, u_near, len);
      color.rgb = mix(color.rgb, color.rgb * vec3(vignette, vignette, color.b / 3), u_dim);
  
      gl_FragColor = color;
  }
  </code></pre>
  
  <p>The correct result is a "vignette" or spotlight effect.</p>
  
  <p>Target Android version: 4.4.2</p>
  
  <p>MainActivity contains</p>
  
  <pre><code>    cfg.useGL20 = true;
  </code></pre>
  
  <p>AndroidManifest contains</p>
  
  <pre><code>    &lt;uses-feature android:glEsVersion="0x00020000" android:required="true" /&gt;
  </code></pre>
  
  <p>Edit: I have set up the projects correctly so that they share assets located in an assets folder in the Android project, including the shader files.</p>