Hi Paul,

2008/11/19 <[EMAIL PROTECTED]>

> Maybe somebody on this list can save me from reinventing the wheel...
>
> I'm looking to get a better understanding of performance issues related to
> uniforms.
>
> How much overhead is there in having a uniform?  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?


Firstly, uniform variables are intented to using in rarely changing  values,
and attributes is used while needing frequently changing values. So using
uniform qualified saves your performance if your value not changing in every
frame. But at that point if you update uniform variable by the
initialized callback or visitor, your variables updating operation will be
needless and I think will reduce your performance. So update your changed
uniform variables by triggered function or operation.

>
>
> 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?  Can I "recompile" the shader on-the-fly (i.e. defining these boolean
> using #define/#if-#endif)?


You can recompile or switch but I don't advice these operation. Only update
your changed values by triggered functions.

>
>
> 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?


It's good choice. Every variable which you send by unifrom variables will
reduce the usable memory by GPU so this is most practical way for me.

>
>
> Also, is there a difference in performance in using four "float" uniforms
> versus setting a Vec4?
>

Actually the preceded answer about memory usage is same situation too. Every
memory usage reduce the performance I think.

P.S : I am not guru' I only use GLSL about 2 months.

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

Regards.

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

Reply via email to