Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: GL Problem with "blending"

  1. #1
    Newbie Newbie
    Join Date
    Aug 2012
    Posts
    3

    GL Problem with "blending"

    Hello everyone,
    I hope you may help me with this problem.
    It might be not a specific OpenGL ES 2.0 problem since it happens on my android phone but when I tried to make a GL application, I got a weird problem.
    My image is partly transparent. Behind the GL Surface is a camera image (for Augmented Reality).
    my problem is, when I make the pixels semi-transparent in the fragment Shader I get a weird result. The brightest pixels seem overexpose. It looks like subtracting color values in Photoshop.
    This doesn't happen without transparency and it happens only with the brightest pixels where I used something like:
    gl_FragColor = vec4(clamp(textureColor.rgb * lightWeighting.xyz, 0.0, 1.0), 0.5);
    I tried clamping in the shader but it didn't really work. I guess it is because there is still the camera picture behind making it "brighter".
    Anyway, I hope someone here has seen that problem before.
    Thank you for your help,
    Tobias


    P.S. I was trying a bit more to solve this problem.
    I found that the Blend-Mode:
    GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA_SATURATE, GLES20.GL_ONE);
    gives a rough solution for this. So when I do that quick-and-dirty solution, it somehow works. But still, there must be a better way to control the "oversaturation"...

    Last edited by TobiasReich; 08-06-2012 at 01:56 PM.

  2. #2
    Newbie Newbie
    Join Date
    Aug 2012
    Posts
    3
    Okay, looks like nobody knows that problem. Maybe there is someone with a Galaxy S3 who might want to help me.
    I made a very small test program to show this.
    You may download the code here:

    https://dl.dropbox.com/u/13527005/CameraGLTest.zip

    or if you only want to test it you will find the .apk here:

    https://dl.dropbox.com/u/13527005/CameraGLTest.apk

    I would be very, very glad for any information about this. Even if you tell me it works perfectly fine on your S3. After all than I would know I have a problem with my phone!
    Thank you very much for your help!
    Tobias

  3. #3
    Newbie Newbie
    Join Date
    Aug 2012
    Posts
    3
    Alright, I got an answer for that.
    The problem was the premultiplication for the alpha values.
    So in the easiest way it is enough to write:

    vec3 color = clamp(textureColor.rgb * lightWeighting.xyz, 0.0, 1.0);
    color *= 0.5; // premultiply by alpha
    gl_FragColor = vec4(color, 0.5);

    Even though I don't see why it worked perfectly fine on older systems and it I'm still not sure how to manage this on Gl1.0 where I can't write my own shader code.
    So hope this helps to anyone who has the same problem!
    Thanks,
    Tobias

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •