Access to depth buffer

What it says on the tin: a place to discuss proposed new features.
Post Reply
natepak
Gnoblar
Posts: 20
Joined: Wed Mar 26, 2008 8:26 pm

Access to depth buffer

Post by natepak » Fri Nov 14, 2008 4:21 am

I'm writing an application that simulates stereo cameras. For part of this project I need to create depth images from each camera in the stereo head. In opengl I could render the scene once from a camera's point of view and get both the color image and the depth buffer. However, in OGRE this doesn't seem possible.

Right now I have to render the scene to both an RGB texture and a float texture. This seems like overkill, and it really decreases performance.

Why is it not possible to access the depth buffer? And would it be possible to get this feature added to OGRE?

Thanks for the help.
0 x

User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
Contact:

Post by Praetor » Fri Nov 14, 2008 4:36 am

This feature has not been available until Dx10. It may also be available with some gl extensions. So, this is a very new feature. The DirectX 10 render system is in progress.
0 x

natepak
Gnoblar
Posts: 20
Joined: Wed Mar 26, 2008 8:26 pm

Post by natepak » Fri Nov 14, 2008 5:12 am

I can't speak about Dx.

However, there has always been the ability to read the depth buffer in opengl through glReadPixels with the GL_DEPTH_COMPONENT option.

Is there some point in the OGRE rendering pipeline that I could safely call glReadPixels and get the depth buffer?
0 x

User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
Contact:

Post by Praetor » Fri Nov 14, 2008 7:14 am

You could try to call it in a RenderTargetListener, listening for a post render target update event.
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19261
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
Contact:

Post by sinbad » Fri Nov 14, 2008 5:24 pm

If this is a regular thing you are far, far better to render the depth to a texture using a shader, potentially via MRT, and then use that later on in your shader pipeline on the GPU. Even though GL lets you read the depth buffer back from GPU to CPU, it's not fast.
0 x

Kodachi_Garou
Kobold
Posts: 34
Joined: Wed Jul 05, 2006 6:07 pm

Re: Access to depth buffer

Post by Kodachi_Garou » Mon Nov 09, 2009 7:16 pm

Hi guys,

Is there any easy way to write the depth of all scene pixels to a texture like you were saying here, Sinbad? This is exactly what I want and I understand it's something fairly common, but I can't for the life of me understand how to do it in Ogre and all google searches have so far been in vain, besides some ellusive comments that it can certainly be done.

Thanks for everything and best regards,

Gonçalo
0 x

Post Reply