question about Framebuffers and depth buffer

BlitzMax Forums/OpenGL Module/question about Framebuffers and depth buffer

AdamRedwoods(Posted 2011) [#1]
Hi, I know this is a rarely visited subforum, but thought I'd post here anyways. it's a complicated question:

Suppose I was drawing an openGL scene, say, several objects at different depths and then ran an FBO-to-texture on one object during the render loop, somewhere in the middle. Now, I could attach a depth buffer, but if I were to render the screen-bound texture quad, the depth buffer doesn't appear do any occlusion from other objects in the scene.

How do I get the foreground objects to occlude the texture quad?

My thoughts are:
1. use the same depth frame buffer for all objects, so it's accessible during the FBO texture. Is this possible? I'll test this first.

2. render the depth to a texture and use a fragment program to display it properly (feed the fp the z-depth position). this is more complex, not sure if i want to go this way.

3. cheat it-- just draw the screen-bound quad in the approximate z-depth using the glFrustum camera.

Anyone with ideas?


AdamRedwoods(Posted 2011) [#2]
Got it, used thought #1.

I did a type of deferred rendered, just accumulating any non-shadered objects into a separate FBO pass. Uses more memory, but it works.


FBEpyon(Posted 2011) [#3]
I know OpenGl provides the void glPolygonOffset(), is this what you might be looking for.. but I know you would only really use this if you were trying to draw two object on top of each other.. But it might help you with what you are trying to do..