Hi Carsten,

Carsten Neumann schrieb:
        Hello Anne,

Anne Braun wrote:
I'm trying to pass a vec3f array to my shader programm using the function:
shader->setUniformParameter(const char* name, const osg:MFVec3f &value)

On shader side I have the parameter: uniform vec3 vectors[NUMPOINTS]
Using a single vector
shader->setUniformParameter("vectors", osg::Vec3f(0.8f, -0.2f, 0.2f)); it works fine. But using a MFVec3f it doesn't work.

uhm, your description suggests you are doing the right thing, passing a MField to setUniformParameter is the way to pass arrays. What exactly is not working? Do you get a compiler error, an error from the driver when it compiles the shader, do you get incorrect values in the uniform? Also, what version of OpenSG is this with and on which platform?

There are no error messages. It seems that the shader gets incorrect values. My OpenSG version is Opem SG 1.8

Here is again my code:
OpenSG:
        MFVec3f parameters = MFVec3f(3);
        parameters.push_back(osg::Vec3f(0.8f, -0.2f, 0.2f));
        parameters.push_back(osg::Vec3f(0.1f, 0.2f, 0.2f));
        parameters.push_back(osg::Vec3f(-0.6f, 0.5f, 0.5f));

        beginEditCP(shader);
                shader->setVertexProgram(vertexShader);
                shader->setFragmentProgram(fragmentShader);
                shader->setUniformParameter("vectors", parameters);
        endEditCP(shader);

Shader:
#define NUMPOINTS 3

uniform vec3 vectors[3];

void main(void)
{
   vec3 vector;

   ...
   for(int i = 0; i < NUMPOINTS; i++)
   {
      vector = vectors[i];
        ...

To be honest, I have no idea how to debug the shader to check whether the values are correct. But using with a single vector instead of a array it works?!

Cheers,
Anne



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

<<attachment: anne-kathrin_braun.vcf>>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to