ShaderComposition mechanism on the osg::State fixed
This commit is contained in:
parent
300ba7aa02
commit
43724f004e
@ -713,19 +713,19 @@ void State::apply(const StateSet* dstate)
|
|||||||
|
|
||||||
applyAttributeList(_attributeMap,dstate->getAttributeList());
|
applyAttributeList(_attributeMap,dstate->getAttributeList());
|
||||||
|
|
||||||
if ((_lastAppliedProgramObject!=0) && (previousLastAppliedProgramObject==_lastAppliedProgramObject) && _defineMap.changed)
|
// Checking if there is no program on the stack or the program is not applied from the AttributeStack (StateSet core mechanism)
|
||||||
{
|
if (_shaderCompositionEnabled && (_lastAppliedProgramObject == 0 ||
|
||||||
// OSG_NOTICE<<"State::apply(StateSet*) Program already applied ("<<(previousLastAppliedProgramObject==_lastAppliedProgramObject)<<") and _defineMap.changed= "<<_defineMap.changed<<std::endl;
|
(_lastAppliedProgramObject->getProgram() != _attributeMap[_lastAppliedProgramObject->getProgram()->getTypeMemberPair()].last_applied_attribute)))
|
||||||
_lastAppliedProgramObject->getProgram()->apply(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_shaderCompositionEnabled)
|
|
||||||
{
|
|
||||||
if (previousLastAppliedProgramObject == _lastAppliedProgramObject || _lastAppliedProgramObject==0)
|
|
||||||
{
|
{
|
||||||
// No program has been applied by the StateSet stack so assume shader composition is required
|
// No program has been applied by the StateSet stack so assume shader composition is required
|
||||||
applyShaderComposition();
|
applyShaderComposition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_lastAppliedProgramObject != 0 && previousLastAppliedProgramObject == _lastAppliedProgramObject && _defineMap.changed)
|
||||||
|
{
|
||||||
|
// Pragma(tic) mechanism must be applied after ShaderComposer
|
||||||
|
// OSG_NOTICE<<"State::apply(StateSet*) Program already applied ("<<(previousLastAppliedProgramObject==_lastAppliedProgramObject)<<") and _defineMap.changed= "<<_defineMap.changed<<std::endl;
|
||||||
|
_lastAppliedProgramObject->getProgram()->apply(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dstate->getUniformList().empty())
|
if (dstate->getUniformList().empty())
|
||||||
@ -784,17 +784,19 @@ void State::apply()
|
|||||||
// go through all active StateAttribute's, applying where appropriate.
|
// go through all active StateAttribute's, applying where appropriate.
|
||||||
applyAttributeMap(_attributeMap);
|
applyAttributeMap(_attributeMap);
|
||||||
|
|
||||||
|
// Checking if there is no program on the stack or the program is not applied from the AttributeStack (StateSet core mechanism)
|
||||||
if ((_lastAppliedProgramObject!=0) && (previousLastAppliedProgramObject==_lastAppliedProgramObject) && _defineMap.changed)
|
if (_shaderCompositionEnabled && (_lastAppliedProgramObject == 0 ||
|
||||||
|
(_lastAppliedProgramObject->getProgram() != _attributeMap[_lastAppliedProgramObject->getProgram()->getTypeMemberPair()].last_applied_attribute)))
|
||||||
{
|
{
|
||||||
//OSG_NOTICE<<"State::apply() Program already applied ("<<(previousLastAppliedProgramObject==_lastAppliedProgramObject)<<") and _defineMap.changed= "<<_defineMap.changed<<std::endl;
|
// No program has been applied by the StateSet stack so assume shader composition is required
|
||||||
if (_lastAppliedProgramObject) _lastAppliedProgramObject->getProgram()->apply(*this);
|
applyShaderComposition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((_lastAppliedProgramObject != 0) && (previousLastAppliedProgramObject == _lastAppliedProgramObject) && _defineMap.changed)
|
||||||
if (_shaderCompositionEnabled)
|
|
||||||
{
|
{
|
||||||
applyShaderComposition();
|
// Pragma(tic) mechanism must be applied after ShaderComposer
|
||||||
|
//OSG_NOTICE<<"State::apply() Program already applied ("<<(previousLastAppliedProgramObject==_lastAppliedProgramObject)<<") and _defineMap.changed= "<<_defineMap.changed<<std::endl;
|
||||||
|
_lastAppliedProgramObject->getProgram()->apply(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_currentShaderCompositionUniformList.empty()) applyUniformMap(_uniformMap);
|
if (_currentShaderCompositionUniformList.empty()) applyUniformMap(_uniformMap);
|
||||||
@ -811,7 +813,7 @@ void State::applyShaderComposition()
|
|||||||
{
|
{
|
||||||
// if (isNotifyEnabled(osg::INFO)) print(notify(osg::INFO));
|
// if (isNotifyEnabled(osg::INFO)) print(notify(osg::INFO));
|
||||||
|
|
||||||
// build lits of current ShaderComponents
|
// build list of current ShaderComponents
|
||||||
ShaderComponents shaderComponents;
|
ShaderComponents shaderComponents;
|
||||||
|
|
||||||
// OSG_NOTICE<<"State::applyShaderComposition() : _attributeMap.size()=="<<_attributeMap.size()<<std::endl;
|
// OSG_NOTICE<<"State::applyShaderComposition() : _attributeMap.size()=="<<_attributeMap.size()<<std::endl;
|
||||||
@ -835,7 +837,8 @@ void State::applyShaderComposition()
|
|||||||
if (_currentShaderCompositionProgram)
|
if (_currentShaderCompositionProgram)
|
||||||
{
|
{
|
||||||
Program::PerContextProgram* pcp = _currentShaderCompositionProgram->getPCP(*this);
|
Program::PerContextProgram* pcp = _currentShaderCompositionProgram->getPCP(*this);
|
||||||
if (_lastAppliedProgramObject != pcp) applyAttribute(_currentShaderCompositionProgram);
|
if (_lastAppliedProgramObject != pcp)
|
||||||
|
_currentShaderCompositionProgram->apply(*this); // NOTE: AttributeStack should not be changed by ShaderComposer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user