HI Martin,

I'm not sure where to start because you code is simply setting up a
render to texture which assigns the texture as the colour buffer not
the depth buffer... so you'll never get the alpha value filled with
depth values.

To capture the depth buffer you'll need to attach a separate texture
to the Camera's DEPTH_BUFFER component.

Robert.

On Sat, Aug 16, 2008 at 11:31 AM, Martin Großer <[EMAIL PROTECTED]> wrote:
> Hello all,
>
>
>
> I want to render a scene to a texture. Here is my implementation of the
> texture and the camera.
>
>
>
> osg::Texture2D* texture = new osg::Texture2D;
>
> texture ->setTextureSize(700, 525);
>
> texture ->setInternalFormat(GL_RGBA);
>
> texture ->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
>
> texture ->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
>
>
>
> // create camera RenderToTexture
>
> osg::Camera* camera = new osg::Camera;
>
> // copy
>
> camera->addChild(…);
>
> camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
>
> camera->setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
>
> camera->setClearColor(clearColor);
>
> camera->setViewport(0,0,700,525);
>
> // set the camera to render befor the main camera
>
> camera->setRenderOrder(osg::Camera::PRE_RENDER, order);
>
> // tell the camera to use OpenGL frame buffer object where supported
>
> camera->setRenderTargetImplementation( osg::Camera::FRAME_BUFFER_OBJECT );
>
> // attach the texture and use it as the color buffer
>
> camera->attach(osg::Camera::COLOR_BUFFER, texture, 0, 0);
>
> // add camera to root
>
> root->addChild(camera);
>
>
>
>
>
> Now, my Problem is that I would like the render the depth buffer information
> in the alpha cannel of the texture. But it doesn't work. :-(
>
> All pixel of the alpha cannel are white??!!
>
>
>
> Can everybody help me?
>
>
>
> Cheers,
>
>
>
> Martin
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to