• Advertisement

Archived

This topic is now archived and is closed to further replies.

Alpha component of textures.

This topic is 6115 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 draw a quad with a texture mapped onto it. I only want certain parts of the texture to be visible.... for example, an icon on the screen, where you can still see other objects behind the "empty" parts... perhaps a little sword in the corner of the screen in an RPG that the player could click on. My question is: what would the RGBA (especially the A) values need to be for the quad and the texture to make that work? Also, is this the proper/best way to do that?

Share this post


Link to post
Share on other sites
Advertisement
Yes, setting the alpha values is the first step. The most logical would be setting them to 0. The next step is to enable alpha testing and here do you also decide which alpha that will pass the test. One example
http://www.ati.com/na/pages/resource_centre/dev_rel/sdk/rage128sdk/OpenGL/Samples/Rage128AlphaTest.html

Share this post


Link to post
Share on other sites
I realize that setting the alpha is the first step... what I''m wanting to know is to set the alpha for WHAT? If I set the alpha to 0.0 for every pixel on the texture, would I still see the quad behind it? OR, does the quad itself need an alpha value of 0.0 before the whole thing would disappear?

I want the non-black parts of the texture to be good and bright.

Share this post


Link to post
Share on other sites
Why not look at the example?
You are thinking of the quad and the texture as two different things but both are proccessed at the same time. If you are setting the alpha values with glColor for the vertices of the quad will the values be interpolated but you want to cut out something like a sword.

You must set the alpha values for the texture this can be done using a paint program such as Paint Shop or Photoshop. The RGB values for the texture does not matter, black or white or something else. Look at the example also the red book covers alpha testing.

Share this post


Link to post
Share on other sites
Okay... sorry. I should''ve looked at the example first. I just got the erroneous impression that you misunderstood my question.

Thanks.

Share this post


Link to post
Share on other sites
check my site ( the most recent demo ) the leftside box is your textures pixel colour, the middle is whats alreay on the screen.
play around with the blending methods and few the final pixels colour on the righthand side of the screen

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
This may be a dumb question...

In the example, there is this line...

glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE);

What is GL_REPLACE? I thought that the only options were GL_DECAL, GL_BLEND, and GL_MODULATE. Is this a Rage specific thing?

Share this post


Link to post
Share on other sites
I probably missunderstood at least part of the question but it is easier to talk about a example. You want to know how the texture data is mixed with the quads data, right?

GL_REPLACE is a standard and means that the RGBA values is from the texture only. Use replace as in the example in your code. From the red book:
"void glTexEnv{if}(GLenum target, GLenum pname, TYPEparam);
void glTexEnv{if}v(GLenum target, GLenum pname, TYPE *param);
Sets the current texturing function. target must be GL_TEXTURE_ENV. If pname is
GL_TEXTURE_ENV_MODE, param can be GL_DECAL, GL_REPLACE, GL_MODULATE, or GL_BLEND, to
specify how texture values are to be combined with the color values of the fragment being processed. If pname is
GL_TEXTURE_ENV_COLOR, param is an array of four floating-point values representing R, G, B, and A
components. These values are used only if the GL_BLEND texture function has been specified as well.
The combination of the texturing function and the base internal format determine how the textures are applied for each
component of the texture. The texturing function operates on selected components of the texture and the color values
that would be used with no texturing. (Note that the selection is performed after the pixel-transfer function has been
applied.) Recall that when you specify your texture map with glTexImage*D(), the third argument is the internal format
to be selected for each texel."

On page 268 do you have tables with the equations. You can download a pdf with the red book for OpenGL 1.1 here at gamedev.

Share this post


Link to post
Share on other sites

  • Advertisement