[osg-users] Shaders with multiple views using ViewportCallback
Robert Osfield
robert.osfield at gmail.com
Mon May 14 00:58:34 PDT 2018
Hi Christoph,
I would have thought it would work, but haven't tried this specifically myself.
Older versions of the OSG didn't have support for calling update
callbacks on view(er) Camera's. I've just had a look at 3.2, 3.4 and
3.6/master and then all look to the have the code to do the update
traversal on the view's master and slave Camera.
A fall-back would be to assign an update/event callback to the Camera
to do the update.
Robert.
On 14 May 2018 at 08:08, Christoph Dohmen <christoph.dohmen at cae.de> wrote:
> Hi Robert,
>
> I just tried the uniform setting for the camera and it worked quite nice.
> But I'm not able to use a callback to do the updating stuff :-(.
>
> I tried to install this callback:
>
>
> Code:
>
> struct ViewportCallback : public osg::Uniform::Callback
> {
> ViewportCallback( osg::Camera* camera )
> : _camera( camera )
> {
> std::cout << "ViewportCallback::ViewportCallback()" << std::endl;
> }
>
> virtual void operator()( osg::Uniform* uniform, osg::NodeVisitor* /*nv*/)
> {
> std::cout << "ViewportCallback::operator()" << std::endl;
> osg::Viewport * vp( _camera->getViewport() );
> uniform->set( osg::Vec4( vp->x(), vp->y(), vp->width(), vp->height() ) );
> }
>
> osg::Camera* _camera;
> };
>
>
>
>
> and set it via
>
>
> Code:
>
> osg::Viewport * vp( viewer.getCamera()->getViewport() );
> osg::Uniform * viewportUniform = new osg::Uniform( "viewport", osg::Vec4( vp->x(), vp->y(), vp->width(), vp->height() ) );
> viewportUniform->setUpdateCallback( new ViewportCallback( viewer.getCamera() ) );
> viewer.getCamera()->getOrCreateStateSet()->addUniform( viewportUniform );
>
>
>
>
> But I don't get any output from operator() nor do I get an updated viewport value in my shader.
>
> What's wrong with this?
>
>
> Thank you!
>
> Cheers,
> Christoph
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=73632#73632
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
More information about the osg-users
mailing list