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 5 of 5

Thread: Identifying the Visible points

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2008
    Posts
    2

    Identifying the Visible points

    I have a 3d model made of around 3000 vertices, i set the camera and view the model by projecting it onto an image using the model view matrices , i also use the gluproject function to find where the vertices of the 3d model are projected onto the image.

    out of the 3000 and odd vertices i would like to know , the list of points visible for the given camera matrix specified.

    EG:- if a 3d model of a sphere consists of 1000 points then , only around 500 points are visible from any camera position , i would like to know if there is any opengl routine/code to identify this set of points

  2. #2
    Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    352

    Re: Identifying the Visible points

    No gl calls here, only geometry.

    Use a octree (or a k-dtree or any spatial structure you like) to memorize the points then read this
    http://www.lighthouse3d.com/opengl/viewfrustum/
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2008
    Posts
    2

    Re: Identifying the Visible points


    In my case all the 3d points are in the view frustum, i would like to get the list of points that form the front faces of the 3d model.

  4. #4
    Junior Member Newbie
    Join Date
    Dec 2008
    Location
    Sweden
    Posts
    4

    Re: Identifying the Visible points

    I don't know of a call that'd give you that list.. A classic trick is to draw all faces using a distinct color for each, reading back the back-buffer and searching for colors. This won't give you the vertices though, only (sometimes partially) visible faces.

    If you're after the forward-facing ones instead of visible ones (which is the same in your sphere case), just dot the normal with the camera vector, whichever is positive is forward facing.

  5. #5
    Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    352

    Re: Identifying the Visible points

    Ops.. sorry, I misunderstand.

    Then is more complex, you have two cases:
    -Vertex belonging to back facing faces.
    -Vertex occluded by other geometry.

    First case is simple, as Fred say, you simply have to make a dot product with the camera.
    For occluded vertex you can use the occlusion query extension to read the number of pixel generated by the draw command, I don't know if it works with points. You have to make a query for every vertex, can be rather slow.
    It's quite old but it's faster than reading the buffer. The opengl 3.0 conditional rendering is based on this.

    Here an example:
    http://www.codesampler.com/oglsrc/og...cclusion_query

    Note: Don't work with transparent object.
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

Posting Permissions

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