Re: [osg-users] Attaching children to the prerender camera

2016-10-04 Thread Trajce Nikolov NICK
good :) .. Glad you found your own way !

Cheers,
Nick

On Tue, Oct 4, 2016 at 4:14 PM, Mary-Ann Zorra  wrote:

> Hi Nick,
>
> I decided to restart this part, and reimplement the whole code.
> Fortunately it worked fine, and my program behaves as expected. I have no
> idea, what the problem was, but thanks for your help!
>
> Mary-Ann
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68846#68846
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
trajce nikolov nick
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Attaching children to the prerender camera

2016-09-21 Thread Trajce Nikolov NICK
Hi Mary-Ann,

hard to tell without seeing the code.. Can you isolate a sample code so I
can run it at my end?

On Wed, Sep 21, 2016 at 3:51 PM, Mary-Ann Zorra  wrote:

> Hi Nick,
>
> Thank you for your answer. I have a callback now, which prints every time
> the texture image to file, when the framebuffer is rendered. I also added a
> debug line to the fragment shader, so I can see, that my shader is able to
> render. But it still can not see the objects in the scene graph, although I
> am sure, that the view and projection matrix is set properly. May you have
> any idea, where I am doing a mistake?
>
> Thanks for your help!
> Mary-Ann
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68684#68684
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
trajce nikolov nick
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Attaching children to the prerender camera

2016-09-21 Thread Mary-Ann Zorra
Hi Nick,

Thank you for your answer. I have a callback now, which prints every time the 
texture image to file, when the framebuffer is rendered. I also added a debug 
line to the fragment shader, so I can see, that my shader is able to render. 
But it still can not see the objects in the scene graph, although I am sure, 
that the view and projection matrix is set properly. May you have any idea, 
where I am doing a mistake?

Thanks for your help!
Mary-Ann

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=68684#68684





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Attaching children to the prerender camera

2016-09-19 Thread Trajce Nikolov NICK
Hi Mary-Ann,

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: http://markmail.org/message/
ccscbkzyxsgmb5vl#query:+page:1+mid:c542rbpj3jdw3v5d+state:results )
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

Hope this helps
Nick

On Mon, Sep 19, 2016 at 5:14 PM, Mary-Ann Zorra  wrote:

> Hi,
>
> 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.
>
> 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 :(
>
> Here is the code:
>
>
> Code:
> camera = new osg::Camera;;
> camera->setViewport(0, 0, m_textureSizeX, m_textureSizeY);
> camera->setClearColor( osg::Vec4() );
> camera->setClearMask( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
> camera->setRenderTargetImplementation( osg::Camera::FRAME_BUFFER_OBJECT,
> osg::Camera::PIXEL_BUFFER_RTT );
> camera->setRenderOrder( osg::Camera::PRE_RENDER );
> camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
> camera->setProjectionMatrix( osg::Matrix::ortho2D(0.0, 1.0, 0.0, 1.0) );
> camera->setViewMatrix( osg::Matrix::identity() );
>
> m_depthTexture = new osg::Texture2D;
> m_depthTexture->setTextureSize(m_textureSizeX, m_textureSizeY);
> m_depthTexture->setInternalFormat(GL_RGBA);
> m_depthTexture->setDataVariance(osg::Object::DYNAMIC);
> m_depthTexture->setFilter(osg::Texture::MIN_FILTER,
> osg::Texture::LINEAR_MIPMAP_LINEAR);
> m_depthTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
> m_depthTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
> m_depthTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
> m_depthTexture->setResizeNonPowerOfTwoHint(false);
>
> m_texImage = new osg::Image;
> m_texImage->allocateImage(m_textureSizeX, m_textureSizeY, 1, GL_RGBA,
> GL_UNSIGNED_BYTE);
>
> camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER),
> m_texImage);
> m_depthTexture->setImage(0, m_texImage);
>
> //m_DBRoot is filled by init(), I checked and the subgraph is there
> camera->addChild(m_DBRoot.get());
> //the root of the scene graph
> root->addChild(camera.get());
>
>
>
>
> Thank you!
>
> Cheers,
> Mary-Ann
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68663#68663
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
trajce nikolov nick
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Attaching children to the prerender camera

2016-09-19 Thread Mary-Ann Zorra
Hi,

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.

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 :(

Here is the code:


Code:
camera = new osg::Camera;;
camera->setViewport(0, 0, m_textureSizeX, m_textureSizeY);
camera->setClearColor( osg::Vec4() );
camera->setClearMask( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
camera->setRenderTargetImplementation( osg::Camera::FRAME_BUFFER_OBJECT, 
osg::Camera::PIXEL_BUFFER_RTT );
camera->setRenderOrder( osg::Camera::PRE_RENDER );
camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
camera->setProjectionMatrix( osg::Matrix::ortho2D(0.0, 1.0, 0.0, 1.0) );
camera->setViewMatrix( osg::Matrix::identity() );

m_depthTexture = new osg::Texture2D;
m_depthTexture->setTextureSize(m_textureSizeX, m_textureSizeY);
m_depthTexture->setInternalFormat(GL_RGBA);
m_depthTexture->setDataVariance(osg::Object::DYNAMIC);
m_depthTexture->setFilter(osg::Texture::MIN_FILTER, 
osg::Texture::LINEAR_MIPMAP_LINEAR);
m_depthTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
m_depthTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
m_depthTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
m_depthTexture->setResizeNonPowerOfTwoHint(false);

m_texImage = new osg::Image;
m_texImage->allocateImage(m_textureSizeX, m_textureSizeY, 1, GL_RGBA, 
GL_UNSIGNED_BYTE);

camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER), 
m_texImage);
m_depthTexture->setImage(0, m_texImage);

//m_DBRoot is filled by init(), I checked and the subgraph is there
camera->addChild(m_DBRoot.get());
//the root of the scene graph
root->addChild(camera.get()); 




Thank you!

Cheers,
Mary-Ann

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=68663#68663





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org