Hello:
I am wondering about how to update an uniform not continually.
here is the sample code:
Code:
osg::Uniform* lightPosU =
new osg::Uniform("LightPosition",osg::Vec3(0,0,1));
bumpMapState->addUniform(lightPosU);
Then I would like to update lightPosU, from Vec3(0,0,1) to Vec3(0,0,10);
As I know Uniform has a setUpdateCallback function which allows continually
update one of concerned nodes once each frame, like this:
Code:
class updateBumpShader : public osg::Uniform::Callback
{
public:
virtual void operator()
( osg::Uniform* uniform, osg::NodeVisitor* nv )
{
float angle = nv->getFrameStamp()->getReferenceTime();
float x = sinf(angle)*.2f;
float y = cosf(angle)*.2f;
osg::Vec3 lightPos(x,y,.6f);
uniform->set(lightPos);
}
};
then using following codes to setUpdateCallback
Code:
lightPosU->setUpdateCallback(new updateBumpShader() );
Is there a method to update the uniform only one time? just modify the value...
I have to customize the setUpdateCallback function?
Or Can I overwrite the uniform then re pass it to Shader?
Thank you!
Cheers,
Nan
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=39282#39282
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org