<div dir="ltr">Hi Mary-Ann,<div><br></div><div>I have recently worked on similar issue and the way how I debug the depth RTT was by rendering the Depth image on a quad (the shader for displaying the Depth image is here: <a href="http://markmail.org/message/ccscbkzyxsgmb5vl#query:+page:1+mid:c542rbpj3jdw3v5d+state:results" target="_blank" style="font-size:12.8px">http://markmail.org/message/<wbr>ccscbkzyxsgmb5vl#query:+page:<wbr>1+mid:c542rbpj3jdw3v5d+state:<wbr>results</a> )</div><div>or simply attach a color texture to the depth RTT as well - might help you to see if your View/Projection matrices are ok too. The link works with Depth textures in general so maybe the code there will give you some inspiration</div><div><br></div><div>Hope this helps</div><div>Nick</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 19, 2016 at 5:14 PM, Mary-Ann Zorra <span dir="ltr"><<a href="mailto:rebebaba2@gmail.com" target="_blank">rebebaba2@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I am pretty new in OSG, so sorry if I am asking a bit noob question. But I am stuck on this problem, and have no idea how I could solve it.<br>
<br>
So I would like to prerender my scene into a framebuffer to have a depth map. I tested everything, my shader seems to work if I am using it in my main rendering pass, and it is being called in my prerender pass too. But for some reason it can not see the objects of the scene, so the depthmap gets black (I do linearize the depth values in the fragment shader too). I think the problem is, that I do not attach the subgraph to the framebuffer camera properly, but I can not figure it out, what I am missing. So please help, I do not have any new ideas anymore :(<br>
<br>
Here is the code:<br>
<br>
<br>
Code:<br>
camera = new osg::Camera;;<br>
camera->setViewport(0, 0, m_textureSizeX, m_textureSizeY);<br>
camera->setClearColor( osg::Vec4() );<br>
camera->setClearMask( GL_COLOR_BUFFER_BIT|GL_DEPTH_B<wbr>UFFER_BIT );<br>
camera->setRenderTargetImpleme<wbr>ntation( osg::Camera::FRAME_BUFFER_OBJE<wbr>CT, osg::Camera::PIXEL_BUFFER_RTT );<br>
camera->setRenderOrder( osg::Camera::PRE_RENDER );<br>
camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );<br>
camera->setProjectionMatrix( osg::Matrix::ortho2D(0.0, 1.0, 0.0, 1.0) );<br>
camera->setViewMatrix( osg::Matrix::identity() );<br>
<br>
m_depthTexture = new osg::Texture2D;<br>
m_depthTexture->setTextureSize<wbr>(m_textureSizeX, m_textureSizeY);<br>
m_depthTexture->setInternalFor<wbr>mat(GL_RGBA);<br>
m_depthTexture->setDataVarianc<wbr>e(osg::Object::DYNAMIC);<br>
m_depthTexture->setFilter(osg:<wbr>:Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LI<wbr>NEAR);<br>
m_depthTexture->setFilter(osg:<wbr>:Texture::MAG_FILTER, osg::Texture::LINEAR);<br>
m_depthTexture->setWrap(osg::T<wbr>exture::WRAP_S, osg::Texture::REPEAT);<br>
m_depthTexture->setWrap(osg::T<wbr>exture::WRAP_T, osg::Texture::REPEAT);<br>
m_depthTexture->setResizeNonPo<wbr>werOfTwoHint(false);<br>
<br>
m_texImage = new osg::Image;<br>
m_texImage->allocateImage(m_te<wbr>xtureSizeX, m_textureSizeY, 1, GL_RGBA, GL_UNSIGNED_BYTE);<br>
<br>
camera->attach(osg::Camera::Bu<wbr>fferComponent(osg::Camera::COL<wbr>OR_BUFFER), m_texImage);<br>
m_depthTexture->setImage(0, m_texImage);<br>
<br>
//m_DBRoot is filled by init(), I checked and the subgraph is there<br>
camera->addChild(m_DBRoot.get(<wbr>));<br>
//the root of the scene graph<br>
root->addChild(camera.get());<br>
<br>
<br>
<br>
<br>
Thank you!<br>
<br>
Cheers,<br>
Mary-Ann<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=68663#68663" rel="noreferrer" target="_blank">http://forum.openscenegraph.or<wbr>g/viewtopic.php?p=68663#68663</a><br>
<br>
<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph<wbr>.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.or<wbr>g/listinfo.cgi/osg-users-opens<wbr>cenegraph.org</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>trajce nikolov nick<br></div>
</div></div>