PDA

View Full Version : Stencil buffer with alpha blending???



Punchey
11-02-2000, 08:34 AM
If, say for example, I draw a quad that is textured with an image that uses blending and is only opaque towards the middle and the edges are completely transparent, does the stencil buffer still flag the pixels "hit" by the whole quad or only the ones that had some degree of opacity? The reason I'm asking is because I'm wanting to render a neat little blended glowing sheild graphic with soft edges and such using a bitmap with alpha values. And I'm using the stencil buffer with this but I only want it to register a "hit" on pixels where the "halo" is actually drawn. Thanks!

DFrey
11-02-2000, 08:46 AM
It will draw the completely transparent pixels unless you are using an alpha test that prevents it from drawing the transparent parts.

Punchey
11-02-2000, 09:01 AM
How do you go about doing an alpha test when rendering to the stencil buffer?

DFrey
11-02-2000, 09:52 AM
First off, alpha testing is completely independent of stenciling. You use alpha testing the same way as you would if you were not using stenciling.

To enable alpha testing, first use glEnable(GL_ALPHA_TEST)

You then need to set which alpha function to use and which reference value to use.

If you only wanted to draw pixels which have an alpha greater than 0, then you'd use glAlphaFunc(GL_GREATER,0)
Be sure to disable the alpha test when you are done drawing all alpha tested polys.

[This message has been edited by DFrey (edited 11-02-2000).]

Punchey
11-02-2000, 11:05 AM
Thanks a TON! I really appreciate your help!