Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm working on a pong game and have recently set up FBO rendering so that I can apply some post-processing shaders. This proceeds as so:

  • Bind texture A to framebuffer
  • Draw balls
  • Bind texture B to framebuffer
  • Draw texture A using fade shader on fullscreen quad
  • Bind screen to framebuffer
  • Draw texture B using normal textured quad shader

Neither texture A or B are cleared at any point, this way the balls leave trails on screen, see below for the fade shader.

Fade Shader

private final String fragmentShaderCode =
        "precision highp float;" +
        "uniform sampler2D u_Texture;" +
        "varying vec2 v_TexCoordinate;" +
        "vec4 color;" +
        "void main(void)" +
        "{" +
        "   color = texture2D(u_Texture, v_TexCoordinate);" +
        "   color.a *= 0.8;" +
        "   gl_FragColor = color;" +
        "}";

This works fine with the Samsung Galaxy S3/ Note2, but cause a strange effect doesnt work on Galaxy S2 or Note1. See pictures:

Galaxy S3/Note2

Galaxy S3/Note2

Galaxy S2/Note

Galaxy S2/Note

Can anyone explain the difference?

edit

Folowing VinceFR's comment, we've tried adding the following. When the renderbuffers are initialised they are briefly bound to the framebuffer and set the background to a uniform buffer with:

    GLES20.glClearColor(backgroundColor[0],backgroundColor[1],backgroundColor[2],backgroundColor[3]);
    GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);

The result is unchanged on the S3, on the S2 it has improved a certain amount, but problems still exist:

Galaxy S2_2

note the 20 in the bottom right corner is supposed to be there.

share|improve this question
    
Have you checked for glerrors? –  Jari Komppa Dec 16 '12 at 17:24
    
Yep, no errors. –  BruceJones Dec 16 '12 at 18:21
2  
try to draw a black background explicitly.I had a similar visual effect when i was drawing on a surface whith no background –  VinceFR Dec 18 '12 at 10:28
    
Make sure your background color's alpha, the depth clear value, the viewport and the scissor area are set up properly. EDIT: why did an old topic come up as new? –  maul Mar 7 '13 at 8:47
    
We tried clearing color and depth on start (didnt help). Doing so between frames would make it so the intended effect didnt work as it is a cumulative effect. viewport is set up properly, it works on GS3 after all. not sure what you mean by scissor area but id imagine thats fine for the same reason. We couldnt find a solution for this so in the end we had to remove the effect. –  BruceJones Mar 19 '13 at 11:21

1 Answer 1

Try to draw a black background explicitly. I had a similar visual effect when I was drawing on a surface with no background.

share|improve this answer
    
Thanks for your answer Vince, have edited the original question accordingly –  BruceJones Dec 19 '12 at 22:56
    
Add, when clearing the FBO, ensure that the viewport is properly set. It appears that you are missing the upper and lower bits. –  rioki Mar 7 '13 at 13:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.