<div dir="ltr">Hi Alberto,<div><br></div><div>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 <a href="https://stackoverflow.com/questions/19125628/how-does-gl-clipvertex-work-relative-to-gl-clipdistance">https://stackoverflow.com/questions/19125628/how-does-gl-clipvertex-work-relative-to-gl-clipdistance</a>). 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.</div><div><br></div><div>Cheers,</div><div>WL</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">wt., 9 kwi 2019 o 12:41 Alberto Luaces <<a href="mailto:aluaces@udc.es">aluaces@udc.es</a>> napisał(a):<br></div><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 want to set a clipping plane for my scene, but it is not working for<br>
instanced geometries. I have not found any resource telling that<br>
clipping planes are ignored by GLSL.<br>
<br>
Simple test: if I make the following modifications to osgforest,<br>
<br>
diff --git a/examples/osgforest/osgforest.cpp b/examples/osgforest/osgforest.cpp<br>
index 5f569de66..d5eb2c0a6 100644<br>
--- a/examples/osgforest/osgforest.cpp<br>
+++ b/examples/osgforest/osgforest.cpp<br>
@@ -36,6 +36,7 @@<br>
#include <osg/TexEnv><br>
#include <osg/VertexProgram><br>
#include <osg/FragmentProgram><br>
+#include <osg/ClipNode><br>
<br>
#include <osgDB/ReadFile><br>
#include <osgDB/FileUtils><br>
@@ -1487,7 +1488,11 @@ int main( int argc, char **argv )<br>
viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));<br>
<br>
// add model to viewer.<br>
- viewer.setSceneData( ttm->createScene(numTreesToCreate, maxNumTreesPerCell) );<br>
+ osg::Node *ttmnode = ttm->createScene(numTreesToCreate, maxNumTreesPerCell);<br>
+ osg::ClipNode *cn = new osg::ClipNode;<br>
+ cn->addClipPlane(new osg::ClipPlane(0, osg::Vec4d(1, 0, 0, -500)));<br>
+ cn->addChild(ttmnode);<br>
+ viewer.setSceneData( cn );<br>
<br>
<br>
return viewer.run();<br>
<br>
...the terrain and the trees are split by my additional clipping plane,<br>
except when the trees are instances; in that case they are drawn as<br>
normal.<br>
<br>
How can I make clipping planes work for instanced rendering?<br>
<br>
Thanks!<br>
<br>
-- <br>
Alberto<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div>