View Full Version : Identifying the Visible points
12-07-2008, 05:15 AM
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
12-07-2008, 10:39 AM
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
12-07-2008, 11:00 AM
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.
12-07-2008, 11:59 AM
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.
12-08-2008, 08:59 AM
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:
Note: Don't work with transparent object.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.