[osg-users] Particle Sorting

Michele Bosi michele.bosi at gmail.com
Wed Sep 5 15:14:12 PDT 2007


Hi,
I am also dealing with transparencies and sorting, in your case maybe
it's enough to mask off z-buffer writing for all the particle systems
using something like:

  osg::Depth* depth = new osg::Depth();
  depth->setWriteMask(false);

  your_geode->getOrCreateStateSet()->setAttribute(depth,
osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);

also be sure that all the rest is ok, like
	your_geode->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

usually for particle systems using this little trick you don't need to
sort at all.
The method has some flaws since the result is not really correct as if
you sorted your particles but since they are moving this shouldn't be
a problem.

Theoretically transparent object that don't write on the z-buffer
should be rendered after the transparent ones that do write on it so
in order to obtain more correct results for your particles you should
create another BIN  (I know you can do it but have no idea how) and
schedule it after TRANSPARENT_BIN.

I just posted a question about polygon sorting, have you ever
implement it with osg or do you have any particular advice share?

Regards,
Mike



More information about the osg-users mailing list