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: Ray Picking vertices

  1. #1
    Intern Newbie
    Join Date
    May 2012
    Posts
    30

    Question Ray Picking vertices

    When ray picking vertices in OpenGL, how does one exclude hidden vertices?

    I always pick the closest vertex, but this vertex may be hidden from view (e.g. behind other objects).
    How can I tell if this picked vertex is hidden or not?

    Ray picking reference:
    http://schabby.de/picking-opengl-ray-tracing/

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,173
    In that article, "ray picking" is independent of OpenGL. So you just exclude the hidden vertices from your search. It even says to intersect "the picking ray with all your visible objects in your scene".

    Now if you mean OpenGL selection mode, that's long-since deprecated and you're better off to use a picking technique implemented on the CPU in your app (such as the "ray picking" approach the articles discusses).

  3. #3
    Intern Newbie
    Join Date
    May 2012
    Posts
    30
    Yes, I'm using ray-tracing to pick vertices, not OpenGL selection mode. I'm not using octrees any other kind of spatial partitioning hierarchy to store my scene.

    My problem is determining whether the vertex I picked is visible or not. This vertex can either be hidden behind another object, or it can be on the backside of a visible object, like a sphere. That article explains the ray-tracing part, but it skips these important details.

    Do people use ray-tracing to solve this problem, or do they use something else, like reading pixels from the color/depth buffer, after the scene has been rendered?
    Last edited by sevenfold; 05-16-2017 at 02:59 PM.

  4. #4
    Intern Newbie
    Join Date
    May 2012
    Posts
    30
    I think I'm just going to use color picking for simplicity. It solves my visibility problem, which means I can throw the whole ray-tracing code out.

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,524
    Quote Originally Posted by sevenfold View Post
    Do people use ray-tracing to solve this problem, or do they use something else, like reading pixels from the color/depth buffer, after the scene has been rendered?
    It depends. On the frequency of picking (on-click versus on-move), the complexity of the scene, and the extent to which the rendered scene is appropriate for picking.

    Neither approach is unambiguously preferable.

    Note that modern OpenGL gives you more options with the rendered approach, as you can render to multiple buffers simultaneously, and also render to integer buffers (so you can store IDs directly, rather than having to encode them as R,G,B triples and hope that they don't get garbled by precision issues).

  6. #6
    Intern Newbie
    Join Date
    May 2012
    Posts
    30
    Quote Originally Posted by GClements View Post
    Note that modern OpenGL gives you more options with the rendered approach, as you can render to multiple buffers simultaneously, and also render to integer buffers (so you can store IDs directly, rather than having to encode them as R,G,B triples and hope that they don't get garbled by precision issues).
    Integer buffers sound interesting, but I've never had a problem with picking colors. Using integer buffers would require a OpenGL 3.0 context.

    If I set glColor3f to (1/255, 2/255, 3/255), then I get back (1,2,3) as bytes. Color precision seems adequate.
    Last edited by sevenfold; 05-17-2017 at 04:19 PM.

Tags for this Thread

Posting Permissions

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