Evan O'Toole wrote:
No matter what value I enter for opacityPercentage, from zero to 100, the 
volume ends up looking the same.

I forgot to mention in my previous post that I'm running osg version 2.6.0.

Hi, Evan,

You're halfway there.   You also need to enable blending:

  osg::StateSet *stateSet = geometry->getOrCreateStateSet();
  stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);


You also will probably want to depth-sort the geometry, and make sure it's drawn later than any opaque geometry (so the blending will work properly):

  stateSet->setRenderBinDetails(1, "DepthSortedBin");



This should work, but I also noticed that you're using an indexed color list. This is a sure-fire way to low frame rates. You've also declared the index array wrong (it should just be UIntArray *colorIndexArray), but that's not important. Keep away from indexed lists. They're only present for backward compatibility. No modern graphics card works well using indexed lists.

Since all of your colors are the same in this case, you can use an overall color, like this:

  //Set the color
  float opacityPercentage(20.0);
  osg::Vec4 color(0.75, 0.75, 0.75, (opacityPercentage / 100.0));  //Light grey

  osg::Vec4Array* colors = new osg::Vec4Array;
  colors->push_back(color);

  //Assign the color to each of the sides
  geometry->setColorArray(colors);
  geometry->setColorBinding(osg::Geometry::BIND_OVERALL);



If you do need different color values, you can use per-vertex colors instead. Don't use per-primitive colors, though (anything with per-primitive binding will also render slowly).


--"J"



_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to