[osg-users] Can I render to a texture AND to the screen in one pass?

Robert Osfield robert.osfield at gmail.com
Wed Mar 11 08:47:26 PDT 2009


Hi Daniel,

I heard along time back that such support exists on the XBox... but I
haven't ever seen any OpenGL extensions that support using the front
buffer as a texture source.

Robert.

On Wed, Mar 11, 2009 at 2:47 PM, Daniel Holz <osgforum at tevs.eu> wrote:
> Hi everyone,
>
> what I want is to obtain the z-Buffer content from a previous render pass (pass1) where I render my scene and use it in a subsequent render pass (pass2). Of course I would like to avoid doing pass1 twice, first to render to the screen and second to render the z-buffer to a texture since I would render my complete scene twice. That's is an overhead that I would like to avoid.
>
> Now the question:
>
> Would it be possible to render the main scene (pass1) in two COLOR_BUFFERS,
> COLOR_BUFFER0 and COLOR_BUFFER1 at the same time?
>
> Then one could set up the camera so that the screen is attached to COLOR_BUFFER0 and a texture 'zBufferContent' is attached to COLOR_BUFFER1.
> How do I do that?
>
> In this case, having multiple render targets, one needs to set up the camera to using FBOs (camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT)) since pixel buffers to not support multiple render targets.
>
> Then, in the fragment shader, one can write to gl_FragData[0] the usual screen color information and pass gl_FragDepth to gl_FragData[1] (gl_FragData[1] = gl_FragDepth), hence obtaining the texture which contains the z-Buffer content.
>
> Would this work?
>
> Regards,
> Daniel
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=8266#8266
>
>
>
>
>
> _______________________________________________
> 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