Results 1 to 5 of 5

Thread: picking and transparency

  1. #1
    Junior Member Newbie
    Join Date
    May 2009
    Posts
    4

    picking and transparency

    Hello,

    I am thinking about using opengl picking vs. ray picking.

    My program is a pretty simple 2D program so picking will probably be sufficient and i won't have to get into reverse projecting and intersection detections.

    There is one thing i couldn't find the answer to and i'd like to know before i choose.

    When i have a polygon that has a texture on it, and part of the polygon is transparent (due to 0 value in the texture alpha channel), when i click on the transparent part will it get picked or not (obviously i'd like it to not get picked).
    Also, in this same case how would ray trace picking help?

    Thanks for your help

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: picking and transparency

    1) alpha blending is quite tricky, as it writes a combination of "before" color and "new" color. But only 1 color value is stored, as well as only 1 depth value.

    2) However I am pretty sure alpha *testing* works as expected, even with "selection" mode, when it is needed to discard the 99% transparent parts.

    3) if alpha test is not working in selection mode, you will have to go to the "color selection" mode. Be sure to enable alpha test and disable blending !

    Drawbacks : slightly more complex, can not return a list of selected objects.
    Advantages : hardware accelerated !!! and somewhat easier to debug, as it is possible to "see" the color buffer.

    Have a read on the GL twiki :
    http://www.opengl.org/wiki/Selection_mechanism
    http://www.opengl.org/wiki/Common_Mi..._Feedback_Mode
    http://www.opengl.org/wiki/Unique_Co...very_Primitive
    http://www.opengl.org/wiki/Specify_An_Exact_Color

  3. #3
    Junior Member Newbie
    Join Date
    May 2009
    Posts
    4

    Re: picking and transparency

    thanks for answering.

    What exactly is alpha testing? Does it mean that each pixel's alpha is tested and if it's above a certain threshold it gets rendered (non blended with whatever's below it) and if its below it doesnt (the pixel below is rendered)?

    in that case, assuming all i want is to "not pick" the parts where the alpha is zero, i could still use the ALPHA_BLENDING mode for the desired effect right?

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: picking and transparency

    fixed :
    each pixel's alpha is tested and if it's above a certain threshold it gets rendered (and blended if blending is active, with whatever's below it) and if its below it doesnt (the pixel below stay as it was)?

    Alpha test and blending are independant.

    Just read the docs :
    http://www.opengl.org/sdk/docs/man/x...lAlphaFunc.xml

  5. #5
    Junior Member Newbie
    Join Date
    May 2009
    Posts
    4

    Re: picking and transparency

    Hey again,

    I read the docs (got it all now) and I did as you said. Doesn't work though. The transparent areas still get picked when i click on them.

    Do i have to enable alpha testing while in selection mode? Its enabled in the opengl init method (i enabled it and disabled blending - just in case).

    Could it be the texture image?
    It a png file and it gets rendered fine (transparency wise) so i figure it's alpha channel is fine.

    I am thinking about color coding instead of picking but how would i render all the texture in one color while still not rendering the transparent parts?

    thanks

Similar Threads

  1. NSOpenGLView visual transparency vs. mouse transparency
    By hidefromkgb in forum OpenGL: macOS
    Replies: 1
    Last Post: 05-12-2015, 01:05 PM
  2. Better way to do transparency?
    By Verdagon in forum OpenGL: Advanced Coding
    Replies: 10
    Last Post: 01-29-2011, 03:30 AM
  3. Z-buffer picking, gluUnProject picking not working
    By Icetigris in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-29-2008, 10:38 AM
  4. Transparency
    By devdept in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 11-15-2006, 12:05 PM
  5. OpenGL window transparency and texture transparency
    By ramalhais in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-15-2002, 09:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean