About "alpha test"

Hey,there…

When we render elements ,such as a triangle,there’re some pixels’s alpha are zero…

And I need to change some data value such as stencil value of this pixel when the alpha is not zero…But how…

As we know glStencilOp allow us to change the stencil value by depth test and stencil test but we can do nothing about “alpha test”…

I’ve think about to create another buffer to instead stencil buffer …But still I can’t find any way to change the data by “alpha test”…

No matter with FBO,MRT and GLSL I have no idea about it …

Any one knows it ?

There is a stencil_export extension (possbily created by AMD) that allows a shader to modify the stencil buffer directly. Therefore, if you can access that, you just need to create another frame buffer and use the previous FBO’s colour attachment as an input texture to the shader. Just check that texture2D (FBOsampler, texcoord).a = some value and you’re good to go.

Thank for your reply…

I have another question :

how to copy the depth buffer data to a texture …

I need the depth data also.

No need. Just attach a depth texture to your framebuffer object. Job done.

Oh,sounds a good idea,but how should I get the data of depth texture in GLSL by pixel coord as texture[0,0]

Thank you .

You can bind it as a uniform sampler2D and sample that texture. You are going to get the values as 0.0 to 1.0 with 1.0 being the far plane and 0.0 being the near plane.