Meaningless Drivel is fun!*
The moose likes Android and the fly likes OpenGL and Camera Preview - blending together gets “over saturated” color - Android Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "OpenGL and Camera Preview - blending together gets “over saturated” color - Android" Watch "OpenGL and Camera Preview - blending together gets “over saturated” color - Android" New topic
Author

OpenGL and Camera Preview - blending together gets “over saturated” color - Android

Tobias Reich
Greenhorn

Joined: Aug 06, 2012
Posts: 3
Hello everyone,

I hope you may help me with this problem.
I'm working on a new Galaxy S3 and found a problem that didn't occur on other phones.
My problem is strange. When drawing my OpenGL models on top of my camera image like that:



So the GLRenderer should be transparent. It actually is. It works fine for all the objects that are opaque as well as the background (where I see the image of the camera)

My problem is, when I make the pixels semi-transparent in the fragment Shader I get a weird result. The brightest pixels seem overexpose when "blending together". And it looks like they got clamped after so the value that brighter than white - loosing probably the first bit - got dark again.
So only the brightest pixels are affected.
I use a simple call like:



So the actual GL-Fragment is clamped and I'm pretty sure it comes from the camera preview itself.
Here is an image that describes my problem:



I hope someone here has seen that problem before. Is there any way of "clamping" both values together since in the Shader I can only clamp the actual rendered fragment somehow. :-(
By the way: it works perfectly fine on my old Galaxy S1 and on the S2 as well.

Thank you for your help,

Tobias
Tobias Reich
Greenhorn

Joined: Aug 06, 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
Tobias Reich
Greenhorn

Joined: Aug 06, 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OpenGL and Camera Preview - blending together gets “over saturated” color - Android
 
Similar Threads
Image to BufferedImage converter
Did older Java have problems with Transparent Images?
Invalidating image cache when using h:graphicImage
OpenGL ES coverage?
embedding a Processing Applet in SWT (Eclipse RCP), otherwise I'd need a text editor engine