depth buffer info

Hi… I’ve been implementing a Maya-like interface where a user can create simple objects, like spheres, cubes, & planes, and can also import OBJ meshes… From here the user can scale, rotate, and translate the objects as desired and then can render the scene out with my own raytracer implemented along with the openGL scene interface… I was wondering if I can somehow get some information from the openGL depth buffer that could be used to speed up my rendering times (especially for large OBJ meshes)… I know that I can get the depth information for each pixel from the depth buffer, but is there someway to also find out which object (or face, when using OBJ meshes) in the scene the depth buffer value refers to? I mean, if I see that the depth buffer for a particular pixel contains a valid z-value, indicating that an object/face/polygon exists at that point, could I also easily find out which object/face/polygon is in the foreground at that pixel? I could use such info to really speed up my rendering times…

Thanks a bunch… and I hope this made sense…

picking/selection/feedback is not typically hardware accelerated.

You could draw into an offscreen buffer, where each face has its own RGB color, un-lit. Then read back the color buffer to finf the ID. (This is also useful for ID based shadows on hardware without depth shadow maps).

However, once something’s rendered, I don’t see how you would speed up rendering – reading back data while rendering is sure to slow down the pipe. You can only look at information from the previous frame if you want any kind of speed.

Last, there are the occlusion query extensions, where you can figure out, for each call to draw primitives, how many pixels actually were drawn because of that (after depth testing). This can be done asynchronousely, which is good for speed.