[osg-users] Array of structs

Robert Osfield robert.osfield at gmail.com
Wed Apr 18 07:38:46 PDT 2018

Hi Marln,

On 18 April 2018 at 15:31, Rowley, Marlin R <marlin.r.rowley at lmco.com>

> Is there an example of setting values in a uniform struct to pass to the
> shaders along with the shader code that uses these values?

I don't recall if we have an example illustrating setting of uniform struct
- I haven't written all the OSG examples or other parts of the OSG code
base so can only easily speak off the top of my head of what I've written
or have worked closely with, the rest I just look up using grep :-)

Although I don't have an example I can point you at, I have used struct in
Uniforms before by declaring the struct in the shader source, then in the
osg::Uniform setup  use a separate osg::Uniform for each uniform i.e.

-- GLSL code:

struct MyStruct
   float a;
   float b;

uniform MyStruct mystruct;

--- C++ code :

stateset->addUniform(new osg::Uniform("mystruct.a", 1.0f));
stateset->addUniform(new osg::Uniform("mystruct.b", 2.5f));

Hope this helps.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20180418/a9811297/attachment.html>

More information about the osg-users mailing list