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

2007-09-11 Thread Mael Blanchard
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@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


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

2007-09-11 Thread David Callu
Hi mael

  never try but probably with osg::Uniform::setArray(FloatArray * array);

David Callu

2007/9/11, Mael Blanchard <[EMAIL PROTECTED]>:
>
> 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@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


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

2007-09-11 Thread Mihai Radu
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
elements).

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 newU = new
osg::Uniform(osg::Uniform::BOOL, m_nameTypeMap[LIGHTS_ARRAY].c_str(),
m_numLights); 
   osg::ref_ptr arr = new osg::IntArray(m_lightsArray,
m_lightsArray + m_numLights);
< ... set values ? ... >
   newU->setArray(arr.get());

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

Cheers
Mihai

David Callu wrote:
> Hi mael
>
>   never try but probably with osg::Uniform::setArray(FloatArray * array);
>
> David Callu
>
> 2007/9/11, Mael Blanchard <[EMAIL PROTECTED]
> >:
>
> 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@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
>   
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org