Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
OpenGL and Camera Preview - blending together gets “over saturated” color
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tobias Reich  
View profile  
 More options Aug 6 2012, 7:21 pm
From: Tobias Reich <tobiasreic...@gmail.com>
Date: Mon, 6 Aug 2012 16:21:42 -0700 (PDT)
Local: Mon, Aug 6 2012 7:21 pm
Subject: OpenGL and Camera Preview - blending together gets “over saturated” color

I'm working on a new Galaxy S3 and found a problem that didn't occur on
other phones like my old Galaxy S1 or the Galaxy S2 - which has almost the
same GPU as the S3.
When drawing my OpenGL models on top of my camera image like this:

mGLView = new GLSurfaceView(this);
mGLView.setOnClickListener(InputManager.getInstance()); GameRenderer
renderer = new GameRenderer(kamera, this);
InputManager.getInstance().currentActivity = renderer;
mGLView.setEGLContextClientVersion(2); mGLView.setEGLConfigChooser(8, 8, 8,
8, 16, 0); setPreserveEGLContextOnPause
mGLView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
mGLView.setZOrderOnTop(true); mGLView.setRenderer(renderer);
setContentView(new CameraView(this), new
LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
addContentView(mGLView, new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));

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. It happens even if I use a
simple call like:

> gl_FragColor = vec4(clamp(textureColor.rgb * lightWeighting.xyz, 0.0, 1.0), 0.5);

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:  

<https://lh6.googleusercontent.com/-XhUolY4rNXA/UCBQnwRqb6I/AAAAAAAAAA...>

I get more and more convinced that it is an "overflow" for the values but
how can I change this? By the way - perhaps it helps - this effect gets
stronger the lower the alpha value of the fragment (the gl rendered one)
is. So somehow it looks like something is compensating/normalizing the
"semi transparent" values.

Is there any way of "clamping" both values together since in the Shader I
can only clamp the actual rendered fragment somehow without asking for the
camera preview values. :-(
Thank you very much! I hope it is not a severe problem,

  Tobias Reich


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain Guy  
View profile  
 More options Aug 7 2012, 3:08 am
From: Romain Guy <romain...@android.com>
Date: Tue, 7 Aug 2012 00:08:57 -0700
Local: Tues, Aug 7 2012 3:08 am
Subject: Re: [android-developers] OpenGL and Camera Preview - blending together gets “over saturated” color

Hi,

You should output your colors with premultiplied alpha. Your code should
look like this:

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

gl_FragColor = vec4(color, 0.5);

On Mon, Aug 6, 2012 at 4:21 PM, Tobias Reich <tobiasreic...@gmail.com>wrote:

--
Romain Guy
Android framework engineer
romain...@android.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tobias Reich  
View profile  
 More options Aug 8 2012, 7:44 am
From: Tobias Reich <tobiasreic...@gmail.com>
Date: Wed, 8 Aug 2012 04:44:20 -0700 (PDT)
Local: Wed, Aug 8 2012 7:44 am
Subject: Re: [android-developers] OpenGL and Camera Preview - blending together gets “over saturated” color

Okay, I will try this but after all, it happens in OpenGL 1.0 as well and
there is no chance to change the shader there.
What could I do there? And why did it work on older phones/android versions
like the S1 and the S2 with Android 2.x?

Am Dienstag, 7. August 2012 09:08:57 UTC+2 schrieb Romain Guy (Google):


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tobias Reich  
View profile  
 More options Aug 8 2012, 8:17 am
From: Tobias Reich <tobiasreic...@gmail.com>
Date: Wed, 8 Aug 2012 05:17:54 -0700 (PDT)
Local: Wed, Aug 8 2012 8:17 am
Subject: Re: [android-developers] OpenGL and Camera Preview - blending together gets “over saturated” color

Alright. I got it.
Now it works. I simply didn't multiply the values!
Man, you helped me a lot! Really! How can I thank you for this??? I was
working on that problem for... ages!
It doesn't explain why it worked perfectly fine on older machines nor does
it explain what to do in OpenGL 1.0 but at least it is a solution!
Thank you very much!
 Tobias

Am Dienstag, 7. August 2012 09:08:57 UTC+2 schrieb Romain Guy (Google):


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Romain Guy  
View profile  
 More options Aug 8 2012, 12:17 pm
From: Romain Guy <romain...@android.com>
Date: Wed, 8 Aug 2012 09:17:05 -0700
Local: Wed, Aug 8 2012 12:17 pm
Subject: Re: [android-developers] OpenGL and Camera Preview - blending together gets “over saturated” color

You should be able to make it work with OpenGL ES 1.0 by choosing another
blending equation.

On Wed, Aug 8, 2012 at 4:44 AM, Tobias Reich <tobiasreic...@gmail.com>wrote:

--
Romain Guy
Android framework engineer
romain...@android.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tobias Reich  
View profile  
 More options Aug 8 2012, 2:24 pm
From: Tobias Reich <tobiasreic...@gmail.com>
Date: Wed, 8 Aug 2012 11:24:21 -0700 (PDT)
Local: Wed, Aug 8 2012 2:24 pm
Subject: Re: [android-developers] OpenGL and Camera Preview - blending together gets “over saturated” color

So than it was just pure "luck" it worked fine with all the previous
versions? What changed? Why can't it just be like it was before?
I mean, its okay now and not really a big problem. - even though I don't
know where I could have seen that information in the API.
Thanks anyway!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »