[osg-users] Can I render to a texture AND to the screen in one pass?
osgforum at tevs.eu
Wed Mar 11 07:47:31 PDT 2009
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 the usual screen color information and pass gl_FragDepth to gl_FragData (gl_FragData = gl_FragDepth), hence obtaining the texture which contains the z-Buffer content.
Would this work?
Read this topic online here:
More information about the osg-users