Hi, I'm having problem with concave polygons. If I use osgUtil::Tessellation it destroys information, that this was a polygon, so I have two options, glue it together or save data (which is memory consuming). It can be done, but the worse problem is in outlining them afterwards with PolygonMode(LINE), because osgUtil::Tessellation doesnt support glEdgeFlag, so the polygon isnt outlined but created triangles are. This can be solved by drawing lines on top of polygon, but that has the same problem, memory consumption. If I use stencil method (http://glprogramming.com/red/chapter14.html - section: "Drawing Filled, Concave Polygons Using the Stencil Buffer") everything is OK, except if I have two overlapping polygons, they cut each other and create a hole between intersection, I'm using this custom Effect:
Code: // implement pass #1 { osg::ref_ptr<osg::StateSet> ss = new osg::StateSet; osg::ref_ptr<osg::Stencil> stencil = new osg::Stencil; stencil->setFunction(osg::Stencil::NEVER, 0, ~0u); stencil->setOperation(osg::Stencil::INVERT, osg::Stencil::KEEP, osg::Stencil::KEEP); ss->setAttributeAndModes(stencil, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); addPass(ss.get()); } // implement pass #2 { osg::ref_ptr<osg::StateSet> ss = new osg::StateSet; // stencil op osg::ref_ptr<osg::Stencil> stencil = new osg::Stencil; stencil->setFunction(osg::Stencil::NOTEQUAL, 0, ~0u); stencil->setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::KEEP); ss->setAttributeAndModes(stencil, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); addPass(ss.get()); } /// I THINK I HAVE TO CLEAR BUFFER HERE BY THIRD PASS, BUT THIS DOESNT WORK: /* // implement pass #3 { osg::ref_ptr<osg::StateSet> ss = new osg::StateSet; // stencil op osg::ref_ptr<osg::Stencil> stencil = new osg::Stencil; stencil->setFunction(osg::Stencil::NEVER, 0, ~0u); stencil->setOperation(osg::Stencil::ZERO, osg::Stencil::KEEP, osg::Stencil::KEEP); ss->setAttributeAndModes(stencil, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); addPass(ss.get()); } */ I was considering writing polygon tessellation shader too, but I find it really complicated and dont know where to start... ... Thank you! Cheers, Filip ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43535#43535 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org