[osg-users] put a uniform array in my GLSL shader ?

Mihai Radu radu at cm-labs.com
Tue Sep 11 10:39:06 PDT 2007

Hi Mael, David

One word of caution, there seem to be some issues with passing Uniform
arrays, from the messages on this list, you could hit some
implementations of GLSL where it will not work very well.

For me it worked on nvidia and an array of bools (I think I had about 8

First create the uniform, then the array for the values, and then set
the array. This is the init code, where no values are being set:

    osg::ref_ptr<osg::Uniform> newU = new
osg::Uniform(osg::Uniform::BOOL, m_nameTypeMap[LIGHTS_ARRAY].c_str(),
   osg::ref_ptr<osg::IntArray> arr = new osg::IntArray(m_lightsArray,
m_lightsArray + m_numLights);
< ... set values ? ... >

If it's about passing packed data in, you can also use a 4x4 float matrix.


David Callu wrote:
> Hi mael
>   never try but probably with osg::Uniform::setArray(FloatArray * array);
> David Callu
> 2007/9/11, Mael Blanchard <maelblanc at gmail.com
> <mailto:maelblanc at gmail.com>>:
>     Hi all,
>     I would like to put in my GLSL shader a uniform array variable,
>     I know how to put a simple float or int value with osg::Uniform,
>     but for an array I don't know
>     Is anyone can help me?
>     thanks
>     Mael.
>     _______________________________________________
>     osg-users mailing list
>     osg-users at lists.openscenegraph.org
>     <mailto:osg-users at lists.openscenegraph.org>
>     http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>     <http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org>
> ------------------------------------------------------------------------
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

More information about the osg-users mailing list