Hi Alberto, You may need to add support for clip planes via gl_ClipVertex or gl_ClipDistance to your shaders (which one depends on GLSL version used -see https://stackoverflow.com/questions/19125628/how-does-gl-clipvertex-work-relative-to-gl-clipdistance). My experience with these vars was not always positive, though. I remember times when I was unable to use them and once had to do my own cliping in vertex shader (=major PITA). But maybe these days newer drivers or OSG version make it easier.
Cheers, WL wt., 9 kwi 2019 o 12:41 Alberto Luaces <[email protected]> napisaĆ(a): > Hi, > > I want to set a clipping plane for my scene, but it is not working for > instanced geometries. I have not found any resource telling that > clipping planes are ignored by GLSL. > > Simple test: if I make the following modifications to osgforest, > > diff --git a/examples/osgforest/osgforest.cpp > b/examples/osgforest/osgforest.cpp > index 5f569de66..d5eb2c0a6 100644 > --- a/examples/osgforest/osgforest.cpp > +++ b/examples/osgforest/osgforest.cpp > @@ -36,6 +36,7 @@ > #include <osg/TexEnv> > #include <osg/VertexProgram> > #include <osg/FragmentProgram> > +#include <osg/ClipNode> > > #include <osgDB/ReadFile> > #include <osgDB/FileUtils> > @@ -1487,7 +1488,11 @@ int main( int argc, char **argv ) > viewer.addEventHandler(new > osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet())); > > // add model to viewer. > - viewer.setSceneData( ttm->createScene(numTreesToCreate, > maxNumTreesPerCell) ); > + osg::Node *ttmnode = ttm->createScene(numTreesToCreate, > maxNumTreesPerCell); > + osg::ClipNode *cn = new osg::ClipNode; > + cn->addClipPlane(new osg::ClipPlane(0, osg::Vec4d(1, 0, 0, -500))); > + cn->addChild(ttmnode); > + viewer.setSceneData( cn ); > > > return viewer.run(); > > ...the terrain and the trees are split by my additional clipping plane, > except when the trees are instances; in that case they are drawn as > normal. > > How can I make clipping planes work for instanced rendering? > > Thanks! > > -- > Alberto > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

