Hi,
i have some problem using osg::Uniform as array to pass to my vertex shader.
I'm using osg 3.0.1 and visual studio 2008 (my video card has opengl 4.1
drivers)
Here my osg code :
Code:
...
program->addShader(vertexfilename);
program->addShader(fragmentfilename);
osg::StateSet* stateset=myModel->getOrCreateStateSet();
stateset->setAttributeAndModes(program);
stateset->addUniform(new osg::Uniform("Kd",osg::Vec3(1.0,0.5,0.5)));
stateset->addUniform(new osg::Uniform("Ks",osg::Vec3(0.5,0.2,0.2)));
stateset->addUniform(new osg::Uniform("Ks",osg::Vec3(0.2,0.1,0.1)));
stateset->addUniform(new osg::Uniform("Shininess",50.0f));
osg::Uniform* arrayIntensity=new
osg::Uniform(osg::Uniform::Type::FLOAT_VEC3,"Intensity",2);
arrayIntensity->setElement(0,osg::Vec3f(1.0,1.0,1.0));
arrayIntensity->setElement(1,osg::Vec3f(1.0,0.5,1.0));
Here my vertex code :
Code:
uniform vec3 Intensity[2];
...
vec3 ads( int lightIndex, vec4 position, vec3 norm )
{
vec3 s = normalize( vec3((lights[lightIndex].Position) - position));
vec3 v = normalize(vec3(-position));
vec3 r = reflect( -s, norm );
vec3 I = vec3(Intensity[lightIndex]);
return (I * ( Ka + Kd * max( dot(s, norm), 0.0 ) + Ks * pow( max( dot(r,v),
0.0 ), Shininess ) ));
}
...
I get no errors, but i get no results too. In detail, i'm trying to apply an
ADS shader effects, but if i use the code above, i get a dark object. If i set
statically the intenisty value in my vertex code, i see the expected
visualisation result.
Could it depend on osg version?
Thank you!
Cheers,
Andrea
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=53153#53153
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org