View Full Version : vertex visibility test
02-24-2004, 07:33 AM
I'm rendering a triangle mesh using opengl.
What I want to know is if each vertex on the mesh is visible (that is, not occluded by any triangles of the mesh) at a given viewpoint. Is there any way (fast or slow) to perform this visibility test?
Any help would be appreciated!
02-24-2004, 09:58 AM
Do you want to perform this visibility enquiry before or after rendering? This will have an effect on the options available to you. For instance, you may want to know the vertex visibility prior to rendering, in order to speed up this rendering. Just speculating here, not quite sure about efficiency of this pre-render process.
If you have already rendered your polygons, you have the option to use z-buffering and determine visibility of the vertex. (Z-buffering here means of course depth buffering). Having a test 3d point (the position of your vertex), you project that to screen coordinates. Using glReadPixels, you can get the z value of the drawn primitive at that screen location. Comparing that with the z-value of the test point, you can determine visibility. You'll have to take into acount special cases, like the test point being behing the eye, but that should not be too much of a problem.
If you haven't rendered your model, hence there is no depth buffer info available (or, simply you don't want to go down that root), the option is to do it the good old fashioned way. Cast a ray from the test point to the eye and see if any intersections with other polygons exist. If not, the point should be visible. You should expect this to be slow, although there are ways to speed it up, which you probably know already (spatial partitioning, boxing, etc.).
Depending on the exact requirements of your taks, we can talk details or variations on these options.
02-24-2004, 12:12 PM
I don't need to know it before rendering.
Thus, it seems your first solution works.
But it looks glReadPixel convert(scale) the values in the depth buffer. Can they be compared to the z-value of the test point?
Thank you for your help.
02-24-2004, 01:52 PM
Maybe this will help with your last question: http://www.cs.unc.edu/~hoff/techrep/openglz.html
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.