[osg-users] How do I access the Z-Buffer content from the last render pass

Robert Osfield robert.osfield at gmail.com
Mon Mar 9 02:04:42 PDT 2009

Hi Daneil,

You'll need to render the scene to a FBO with texture attached to as
the depth buffer, then reuse this texture in the second pass.


On Mon, Mar 9, 2009 at 1:30 AM, Daniel Holz <danielh at cm-labs.com> wrote:
> Hi osg-users,
> is it possible to access the Z-Buffer content from a render pass 1 in the
> shaders during a second render pass 2 if I do not clear the Z-Buffer content
> in pass 1?
> In my project I render my scene in pass 1 and set the clear mask for pass 2
> to "0", hence not clearing neither the color nor the depth buffer:
>   pCamPass2->setClearMask(0);
> Now, how do I read out the Z-Buffer content of the gpu for a given pixel in
> the fragment shader of pass2?
> Trying to read from gl_FragDepth did not work.
> Any suggestions?
> Cheers
> Daniel
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

More information about the osg-users mailing list