From: Christoph F. <c.f...@gm...> - 2012-06-29 13:01:24
|
Hi all, I would like to render a depth image via FBO with a current OpenSG 2.0. Quite a common operation, so can someone post a code fragment for it perhaps? I have tried the code below so far without success. Getting the color image works without any problems .. void computeHeightfieldImage (OSG::Node* root, OSG::UInt32 x, OSG::UInt32 y, OSG::NodeUnrecPtr& stageN, OSG::ImageRefPtr& image) { // create FBO image = OSG::Image::create(); image->set(OSG::Image::OSG_L_PF, x, y, 1, 1, 1, 0.0, 0, OSG::Image::OSG_FLOAT32_IMAGEDATA); OSG::FrameBufferObjectRefPtr fbo = OSG::FrameBufferObject::create(); OSG::RenderBufferRefPtr depthBuf = OSG::RenderBuffer::create(); depthBuf->setImage(image); depthBuf->setInternalFormat(GL_DEPTH_COMPONENT32); OSG::RenderBufferRefPtr texBuf = OSG::RenderBuffer::create(); texBuf ->setInternalFormat(GL_RGB); // make the fbo render to the texture fbo->setColorAttachment(texBuf, 0); fbo->setDepthAttachment(depthBuf ); fbo->editMFDrawBuffers()->push_back(GL_COLOR_ATTACHMENT0_EXT); fbo->setWidth (x); fbo->setHeight(y); depthBuf->setReadBack (true); fbo->setPostProcessOnDeactivate(true); .. } Thanks, Christoph -- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de |