Alpha values

03460e685202f2d6efc0df9e9727975e
0
martin 101 Mar 15, 2003 at 00:35

Hi all,

I try to implement something called Opacity Shadow Mapping by which it is possible to calculate shadows of semi-transparent
objects. In order to do this, I have to render the scene several times with special clipping parameters. After rendering,
I will read back the resulting alpha values from the color buffer. But unfortunately, all alpha values are one. I am using
the blending equation GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA. My question: How can I render the scene and
get back different alpha values at different positions? To get more precisely: When I render a quad textured with a bitmap
that has an alpha value of 0.6, I want this 0.6 appear in the color buffer again. When I render this scene again with another
quad lying over the other, I want the two alpha values properly accumulated and stored again in the color buffer.

Any help will be appreciated,
MK

8 Replies

Please log in or register to post a reply.

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Mar 15, 2003 at 08:34

if you look at the scene, make sure that the quads do have an alpha of 0.6. ie. see if you can see through them. If that’s OK, then it’s a problem in the reading process.

03460e685202f2d6efc0df9e9727975e
0
martin 101 Mar 15, 2003 at 14:04

Sorry, that’s not my problem. I know how to texture transparent objects, but I want this alpha value in the framebuffer and I
have no idea how to do this. The alpha values in the framebuffer are contstantly one after the rendering process.

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Mar 15, 2003 at 15:08

well, that’s not the problem.. Do the colour values get read right?

03460e685202f2d6efc0df9e9727975e
0
martin 101 Mar 15, 2003 at 15:20

I read the values from the framebuffer with
glReadPixels(0,0,512,512,GL_ALPHA,GL_UNSIGNED_BYTE,map);
All alpha values turn out to be 1.

Fdbdc4176840d77fe6a8deca457595ab
0
dk 158 Mar 15, 2003 at 20:08

How are you rendering the screen? Are you sure you are rendering transperant objects?
Btw, read up on ‘glReadBuffer()’ to specify the buffer you want to read from.

03460e685202f2d6efc0df9e9727975e
0
martin 101 Mar 15, 2003 at 23:59

Yes, I’m sure that I am rendering transparent objects, the color values are all fine blended together.
I am using glReadBuffer(GL_BACK) to read from the back buffer (I’m using double buffering).
There is no alpha buffer from where I can read the intermediate alpha values.

03460e685202f2d6efc0df9e9727975e
0
martin 101 Mar 16, 2003 at 01:01

Hmm, I see where the problem is…
I tried a demo program using GLUT. When I initialize GLUT with GLUT_RGBA and especially with GLUT_ALPHA,
it works. Unfortunately, I am not using GLUT, but Trolltechs Qt OpenGL component. I have to look for an
equivalent option there.

E05263ec846eb85da803f56e2917962d
0
Noor 101 Mar 16, 2003 at 01:52

Hmm :rolleyes: . When I read the help menu concerning the problem you had, the help menu did not say anything about GLUT. But anyway congratulations :) .