Hi Mike,
thanks for the hint, but this is not the failure. This is the normal
way to bind the program to the different state sets and it works.
Meenwhile I think that I've a problem with the actualization of the
program and/or shaders. So I've called the setDirty methods on all
but with no positive result ...
Best regards,
Christian
Mike Weiblen wrote:
This caught my eye:
state->setAttributeAndModes(prg.get(), osg::StateAttribute::ON);
}
// otherwise bind the program and deactivate it.
else{
state->setAttributeAndModes(m_program.get(),
osg::StateAttribute::OFF);
}
osg::StateAttribute::ON/OFF does not work on osg::Program, as GL does
not use glEnable/glDisable on glPrograms. GL disables an active
glProgram with glUseProgram(0); the equiv in OSG is to attach an "empty"
osg::Program (one that has no osg::Shaders attached) Perhaps that is
confusing the OSG state manager, causing this failure?
-- mew
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:osg-users-
[EMAIL PROTECTED] On Behalf Of Christian Heine
Sent: Thursday, June 05, 2008 11:34 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Issue on sharing shaders between objects
Hello,
i've played arround with this issue, but i could solve it until now.
First i thought there may be a problem with the reusage of the
program, but when i copy it instead of sharing, nothing happends, i
got the same failure.
// finaly bind the program and activate it if it is user enabled
if(this->m_userEnabled){
for(uniforms_t::iterator uniIter =
m_uniformCache.begin();
uniIter != m_uniformCache.end();
uniIter ++){
// add all uniforms from the list to the state
state->addUniform((*uniIter).second.get(),
osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE |
osg::StateAttribute::PROTECTED);
}
/* fake for copy program
osg::ref_ptr<osg::Program> prg = new osg::Program;
prg->addBindAttribLocation("tangent",
osg::Drawable::ATTRIBUTE_6);
prg->addBindAttribLocation("binromal",
osg::Drawable::ATTRIBUTE_7);
boost::shared_ptr<OSGTechnique> technique =
this->getOSGTechnique(AbstractTechnique::VERSION_PS30);
// convert BinRev shader params to osg::Uniform and
osg::Attribute objects
for( unsigned int i = 0;
i < technique->getNumberOfShaders();
i++)
{
boost::shared_ptr<OSGGLSLShader> shader =
boost::dynamic_pointer_cast<OSGGLSLShader>(technique->getShader(i));
prg->addShader(shader->getShader().get());
}
*/
state->setAttributeAndModes(prg.get(),
osg::StateAttribute::ON);
}
// otherwise bind the program and deactivate it.
else{
state->setAttributeAndModes(m_program.get(),
osg::StateAttribute::OFF);
}
}
There is nothing realy special...
I've attached an image to show what's going wrong.
Has anyone a hint what could be going wrong? I'm running out of
ideas..
Best regards,
Christian
[EMAIL PROTECTED] wrote:
Hello,
i've successfully implemented a simple dot3 object shading for my
scene and
it works fine with single objects. Now i try to share the shaders
between
different objects in the scene and got some trouble:
To share the shaders i've one osg::Program, where i've added two
osg::Shader
objects. The osg::Program instance is shared between the objects and
applied
to their osg::StateSet objects. The required osg::Uniform objects
are
created
explicit for each object and bind to their osg::StateSet in a
separated process.
So only the osg::Program and osg::Shader are Shared (later i will
share the
equal uniforms too).
The shader works, but it's effected on all objects equals to the
object where
the osg::Program has applied first. I.e. i've added two normal
mapped
cubes in
the scene. When i set the light between both cubes i expect that
both
cube faces
are enlighted arround the light, but on the 2nd cube the thame face
of the first
cube is enlighted...
Have i consider something special for the sharing of (object)
shaders
between
objects?
Best regards,
Christian
_______________________________________________
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