Jump to content
  • Advertisement
Sign in to follow this  
ViperG

OpenGL OpenGl Alpha Buffer?

This topic is 4823 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
Advertisement
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
glBlendFunc(GL_DST_ALPHA, GL_ZERO);
This is assuming that 0 alpha in your mask texture means "not to draw".

or you can use the common transparency method

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!