Sign in to follow this  

16bit Alpha Test?

This topic is 4775 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to use an alpha test to block certain parts of a texture. However, the values in the alpha texture are 16 bits (so I have a 24 bit RGB texture and a 16 bit alpha texture). It it possible to use the alpha text with 16 bit values? Kelly

Share this post


Link to post
Share on other sites
The OpenGL header file (gl.h) defines GL_ALPHA for up to 16-bits.

#define GL_ALPHA4 0x803B
#define GL_ALPHA8 0x803C
#define GL_ALPHA12 0x803D
#define GL_ALPHA16 0x803E

I assume you'd send this as a parameter to glTexImage.

- carb

Share this post


Link to post
Share on other sites
Thanks for the response. Actually, I already have a 16 bit alpha texture. What I need to be able to do is perform the alpha test on 16 bit values.

Here's a better description of the problem:

I have 3D rendered image data in a proprietary format. The data consists of many different structures, each of which can be highlighted and removed from the image. As of now, every time a user clickes on a structure, we peform a look up with the mouse coordinates to get the ID of the structure. With that ID we are able to recreate the image that is being displayed, update the texture, and display it with the structure highlighted. With some optimizations we were able to get this to be fairly fast (less than a second between clicking and the new image being displayed).

However, now we want to have mouse-over highlighting. The above process is too slow to do every time the mouse moves to a different structure. I can use GL to do the blending for me (our highlighting is a 50-50 blend with the pixel color and some other color), but that requires being able to set the alpha value for all the pixels that make up the current structure that the mouse is over. Both the stencil buffer and alpha test could be used for this, except they only use 8 bits (as far as I can tell) and we have IDs ranging from 0 to 11000. We also have the potential to have more than 256 structures visible at the same time, so I can't just map the visible ids to fit in a single byte.

I would like to just do this in a shader, but we want it to work on cards that don't support fragment shaders. If anyone has an idea for this, I would really appreciate it. Thanks!

Kelly

Share this post


Link to post
Share on other sites
i dont understand 100% what u want but
perhaps u wanna look into floating point buffers,
how ru selecting the struct (opengl selection, drawing each object in a diff color, and reading back, casting a ray in the scene)

Share this post


Link to post
Share on other sites
Thanks for the reply. Here's a link that will explain what I'm talking about (a picture is worth a thousand words).

Say the user clicks on the pectoralis muscle. That muscle is a structure with a certain ID. Right now, we loop through the data, and when we find a pixel with the correct ID, we blend that pixel with a highlight color.

We want to change it so the user can just mouse-over a structure to have it highlighted. It's easy enough to make an Alpha-16 texture that has the IDs of all the visible structures. I would like to be able to do an alpha test with the ID that the mouse is over, and let GL throw away any fragments where the IDs don't match. However, the values seem to be 8 bit floats.

Do you have a link with information on floating point buffers? Thanks.

Kelly

Share this post


Link to post
Share on other sites

This topic is 4775 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this