Paul, >From my perspective :
How much overhead is there in having a uniform? GLSL? Not much. > If there only a performance hit if the uniform changes values or every > frame. What if I change the Uniform in OSG to exactly the same value it > already has, would there be a performance hit? > I regularly use uniforms that change every frame, and I can't say I've noticed any performance penalty (in the context of an app that is doing "real work"). > I have uniforms that might not change values very often. Some are simply > boolean flags. Can I have different shaders and somehow switch between them? > Yes. Some people use uniforms and in-shader dynamic branching to control the operation of shaders. (Some people obviously have too much GPU power for their own good ;). Me, I'm often stuck with older cards that can't support dynamic branching very sensibly, and so this kind of shader kills me. ). An alternative is to have a switch node, whose children all have different shaders on them, and who are all the parent of your object. There's a separate thread on this topic going on at this exact time with very similar issues to this approach, bearing in mind that shaders form part of the stateset. Can I "recompile" the shader on-the-fly (i.e. defining these boolean using > #define/#if-#endif)? Bad idea in general, for performance reasons. > > In some cases, I have variables which can change within the shader, but I > know these values when I create the scene graph so I currently use #define > instead of passing them as uniforms (which will ever only have one > value). Does this gain me much in performance? In general, yes - it's certainly better for performance (the extent is GPU dependent, obviously) and this solution is better for older hardware that doesn't support dynamic branching. > Also, is there a difference in performance in using four "float" uniforms > versus setting a Vec4? > Off the top of my head, I'm not sure - this is probably driver dependent (good GLSL compilers might pack this up automatically). You might try the OpenGL / GLSL forums for this. Hope that helps, David
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

