Hi Colin,

As a general rule it's best to minimize the number of StateSet and
associated StateAttribute/Uniform/Mode changes, both form the OSG's
CPU cost, as well as the cost down on the GPU with stalling the
graphics pipeline with state changes.  Uniforms in particular can be a
very expensive state change as some drivers treat uniforms as
constants and recompile or relink the shader program.

The way to avoid using lots of separate Uniforms is to move to using
vertex attributes attached to an osg::Geometry.  In the
osgParticular::PrecipitationEffect I tackled this by sharing a single
shared geometry and then having a custom drawable that uses this
shared geometry to send down most of the data and then in addition
sets the vertex attribute I wanted to vary.  The osgforest example
also does a similar trick in the GLSL path.

Robert.

On Fri, Aug 15, 2008 at 9:32 AM, Middleton, Colin (GE EntSol,
Intelligent Platforms) <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm using a geometry shader to do particle animation for a splash
> special effect. I am using a few uniforms, one of which is the time at
> which the splash starts and others that contain values that are shared
> among the different splashes.
> I am applying the StateSet containing the osg::Uniforms and the
> osg::Program to a group above the splash geometry, I do this everytime I
> create a new splash, which is shallow copied from a file I load.
>
> Now this seems to cause a lot of CPU load when I have lots of splashes
> active. I believe this is because each splash has a different StateSet,
> with all the elements equal apart from the Uniform representing the
> splash time. ( Profiling shows me that lots of CPU time is used in
> osgUtil::SceneView::draw, which is mostly spent in
> osgUtil::StateGraph::moveStateGraph and osg::State::apply ).
>
> If I reuse the same StateSet, I get good performance, but of course only
> my first splash is visible as the start time.
>
> Is there better mechanism to get the splash start time into the shader?
> Would having the start time on a different StateSet on a node below the
> one with the common state help performance?
>
> I don't have a very good grasp of how the state sorting works in OSG so
> any advice would help lots.
>
> Cheers,
>
> Colin.
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to