Advertisement Jump to content
Sign in to follow this  

OpenGL OpenGl Alpha Buffer?

This topic is 4973 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

Does Opengl have some sort of buffer, like a stencil buffer, but it is used for textures? Aka, I don't care about polygons, I just want it to draw in the texture alpha from a textured polygon. Stencil buffer only draws polygons, But I need the texture information. Instead of using the Stencil Buffer to mask out parts of the polygon, I want to use a buffer to mask parts of the textures on polygons. Also if I draw a polygon into the stencil buffer, using glAlphaFunc, would that only draw the texture, if I did (gl_greater, 0.0); ?

Share this post

Link to post
Share on other sites
More like Alpha testing, then storing the result in some sort of screen buffer.

So the whole screen of pixels will be 0's, except the part that was stored in the buffer (1's)

then I can go ANDING to draw another texture, and it will only draw if the result is 1.

In other words, I want to stencil buffer in a texture's alpha channel, not the whole polygon itself.

Share this post

Link to post
Share on other sites
Eh i thought alpha testing discards fragments before they reach the stencil buffer.(Might be wrong i dont use stencil)

Meaning you could draw your initial mask texture with alpha testing and stencil buffer.
The parts in your texture with 0 alpha will not make it into the stencil buffer.

But assuming im wrong, i do know that the framebuffer has an alpha channel meaning it stores the alpha value of texels which make it to the framebuffer. Using glBlend();

In RGB mode, pixels can be drawn using a function that blends the incoming (source) RGBA values with the RGBA values that are already in the framebuffer (the destination values).

So your blending mode would probably be something like

your new pixels * alpha buffer value,your mask in the framebuffer
This is assuming that 0 alpha in your mask texture means "not to draw".

or you can use the common transparency method


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!