Hi Clayton,
On 22/12/09 2:30 PM, Clayton Bluhm wrote:
> I am new to OSG. I am trying to draw a lot of spheres into a scene. By lots I
> mean on
> the order of a 100,000 or so. This really brings my simple test app to its
> knees. Here is
> the current way I am drawing these spheres:
>
> osg::Sphere *unitSphere = new osg::Sphere(osg::Vec3(0,0,0),5.0);
> osg::ShapeDrawable* unitSphereDrawable = new osg::ShapeDrawable(unitSphere);
>
> for(1...100,000)
> {
> osg::PositionAttitudeTransformation *shpereXForm = new
> osg::PositionAttitudeTransformation();
> sphereXForm->setPosition(position);
> osg::Geode* unitShpereGeode = new osg::Geode();
> sphereXForm->addChild(unitSphereGeode);
> unitSphereGeode->addDrawable(draw);
> GetScene()->AddDrawable(unitSphereGeode);
> }
>
> Our current product uses straight 2D OpenGL calls and uses points instead of
> spheres
> to draw the dataset. We are currently porting everything to 3D using OSG and
> found that we
> might have to do something unique when it comes to displaying the dataset we
> are trying to
> display. The dataset we are trying to draw doesn't persist over time. Its
> there one second
> and gone the next. I need a quick way to draw lot of spheres very quickly. I
> have started
> looking into overriding the Camera::DrawCallback and add raw OpenGL calls. Is
> this the
> right path to look down or is there something easier?
Any particular reason why you're switching from points to spheres? Drawing
100,000
spheres (underneath a PAT, too, so a separate matrix for each!) with maybe ~100
vertices
will certainly perform worse than simply drawing 100,000 points.
Some ideas:
- stay away from ShapeDrawable if performance matters
- sphere tesselation is probably way to high (as mentioned)
- having a flat hierarchy of PAT/Geode is bad for culling
- share the Geode (like you are sharing the ShapeDrawable) by attaching it to
different
PATs (affects memory footprint)
- have a look at instancing to avoid getting bogged down in the cull traversal
- use point sprites instead?
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org