Hello,
I am trying to get access to Depth Information using FBOViewport Object
but the data is always 0.
Is it possible to use FBOViewport to render the Depth of a 3D scene into
a texture to be used by a shader?
I tried to follow the FBOViewport example of the tutorial and took a
look to the existing code of the ShadowViewportMap which acess to depth
information.
But I have no clue what I am doing wrong.
Any Clue?
Best Regards.
This the code, I used to initialize the image, the texture and the
FBOViewport. I tried several format but I was unsuccessfull.
ImagePtr imgDepth = Image::create();
beginEditCP(imgDepth);
//imgDepth->set(Image::OSG_RGBA_PF, ::fboWidth, ::fboHeight);
imgDepth->set(Image::OSG_L_PF, ::fboWidth, ::fboHeight,
1, 1, 1, 0, NULL,
Image::OSG_UINT8_IMAGEDATA, false);
endEditCP(imgDepth);
beginEditCP(fboTextureDepth);
fboTextureDepth->setMinFilter(GL_LINEAR);
fboTextureDepth->setMagFilter(GL_LINEAR);
fboTextureDepth->setTarget(GL_TEXTURE_2D);
fboTextureDepth->setInternalFormat(GL_DEPTH_COMPONENT_ARB);
fboTextureDepth->setExternalFormat(GL_DEPTH_COMPONENT_ARB);
fboTextureDepth->setWrapS(GL_CLAMP_TO_EDGE);
fboTextureDepth->setWrapT(GL_CLAMP_TO_EDGE);
fboTextureDepth->setEnvMode(GL_REPLACE);
//new depth end
fboTextureDepth->setImage(imgDepth);
endEditCP(fboTextureDepth);
// add background
GradientBackgroundPtr bg = GradientBackground::create();
beginEditCP(bg);
bg->addLine(Color3f(0.0, 0.0, 0.0), 0.000);
bg->addLine(Color3f(0.5, 0.5, 0.5), 1.000);
endEditCP(bg);
// setup camera
PerspectiveCameraPtr fboCam = PerspectiveCamera::create();
beginEditCP(fboCam);
// we already compensated aspect ratio with the texture/fbo sizes
fboCam->setAspect(1.0);
fboCam->setFov(osgdegree2rad(60));
fboCam->setNear(0.01);
fboCam->setFar(100);
fboCam->setBeacon(::fboCamBeacon);
endEditCP(fboCam);
// create FBOViewport
::fboVP = FBOViewport::create();
beginEditCP(::fboVP);
::fboVP->setSize(0, 0, ::fboWidth - 1, ::fboHeight - 1);
::fboVP->setStorageWidth(::fboWidth);
::fboVP->setStorageHeight(::fboHeight);
::fboVP->setBackground(bg);
::fboVP->setCamera(fboCam);
::fboVP->setParent(gwin);
// attach texture as render target
::fboVP->getTextures().push_back(fboTextureDepth);
::fboVP->setRoot(fboScene);
::fboVP->setGenDepthmaps(true); //not sure is really needed?
::fboVP->setDirty(true); //not sure is really needed?
::fboVP->setFboOn(true); //not sure is really needed?
endEditCP(::fboVP);
--
___________________________________________________
Bruno Rodrigues De Araujo
Intelligent MultiModal Interfaces Group - INESC-ID
Department of Information Systems and Computer Science
IST/Technical University of Lisbon
Avenida Professor Cavaco Silva, Room 2-N9.21
2780-990 Porto Salvo, Portugal
Tel: +351.21.4233566 (INESC-ID TagusPark)
Tel: +351.21.3100271 (INESC-ID Alameda)
Fax: +351.21.3145843
mailto:[EMAIL PROTECTED]
http://immi.inesc-id.pt/~brar
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users