Sorry if the question is not worded well, I'm a new to both 3D and OpenGL.

How could I go about obtaining the 3D coordinates of the occluding object, at the point where occlusion is happening (i.e. the 'intersection' of the object in front/closest to the screen)?

Just to offer a [very] rudimentary, visual, example, if you were to form an index-finger cross, with your right hand closest to your face, I'd like to know the coordinates of the part of your right finger which obscures the other finger (obviously back within the OpenGL context - no jokers ;-) ).

If there is a way to find out both about the occluder (hider) and the occluded (hidden) objects in OpenGL, then that would be of great use, also.



  • \$\begingroup\$ Sounds like a problem which could be solved using BSP. I could think of a couple of ways to get the overlapped pixels (using stencil or alpha), but getting back to 3d would be a hassle. With BSP you should be able to calculate the actual overlapping geometry. \$\endgroup\$ – Jari Komppa Jan 16 '11 at 9:22
  • \$\begingroup\$ What are yor objects? Points? Lines? Polygons? If they are polygons, there is not only one intersection point. Points, lines are always easy. For polygons i have solution, which needs off-screen rendering (rendering to texture). Is this ok for you as a beginer?. @JariKomppa - I have no idea how to use BSP for this, please share your idea how to do it. \$\endgroup\$ – Notabene Jan 16 '11 at 11:49
  • \$\begingroup\$ I hadn't giving the Lines/Points/Polygons question much thought, but now I have, they'd probably be Lines (I'm visualising "beams" that might also be formed by cubes, in a editor for example). JFYI, I'm a corporate Java/C# dev, more at home with MySQL and Servlets, but I'm hoping to retarget my code skills at the App-Dev goldmine ;-), thanks. \$\endgroup\$ – Big Rich Jan 16 '11 at 14:25
  • \$\begingroup\$ Do you know where on the screen your intersection is? \$\endgroup\$ – Notabene Jan 16 '11 at 23:24

Finding the foremost object can be thought of as 'picking'. There are basically three obvious ways to do it - using GL's selection mode, using unique colours for objects when rendering them and finally doing it via geometry on the CPU rather than using OpenGL.

If using OpenGL, you could draw the scene back to front, doing a test after each draw, to determine the next-most-top object at that location.

Ultimately, using ray intersections with octrees is going to be a far more professional solution.

  • \$\begingroup\$ Will, I'll have to do a little background research on the techniques you mention before I can fully understand which way to go, but many thanks. As for whether my occlusion calculation is performed via OpenGL or non-library coding, I have no overall preference, other than I thought I'd employ OpenGL for 3D rendering, due to its universal usage (C/C++, C#, Java etc.). \$\endgroup\$ – Big Rich Jan 16 '11 at 16:21
  • \$\begingroup\$ I deleted my previos comment, because it wasnt right. \$\endgroup\$ – Notabene Jan 16 '11 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.