Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: About "alpha test"

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    7

    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 ?

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161
    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.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    7
    Quote Originally Posted by BionicBytes View Post
    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.

  4. #4
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161
    No need. Just attach a depth texture to your framebuffer object. Job done.

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    7
    Quote Originally Posted by BionicBytes View Post
    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 .

  6. #6
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,256
    Quote Originally Posted by FireInDark View Post
    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.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •