Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.



share|improve this question
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. –  Jari Komppa Jan 16 '11 at 9:22
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. –  Notabene Jan 16 '11 at 11:49
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. –  Big Rich Jan 16 '11 at 14:25
Do you know where on the screen your intersection is? –  Notabene Jan 16 '11 at 23:24

1 Answer 1

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.

share|improve this answer
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.). –  Big Rich Jan 16 '11 at 16:21
I deleted my previos comment, because it wasnt right. –  Notabene Jan 16 '11 at 23:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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