Double buffer view-dependent data stateset

pull/2993/head
AnyOldName3 4 years ago
parent 98b2d5d921
commit ce98d7053b

@ -749,7 +749,8 @@ MWShadowTechnique::ViewDependentData::ViewDependentData(MWShadowTechnique* vdsm)
_viewDependentShadowMap(vdsm)
{
OSG_INFO<<"ViewDependentData::ViewDependentData()"<<this<<std::endl;
_stateset = new osg::StateSet;
for (auto& perFrameStateset : _stateset)
perFrameStateset = new osg::StateSet;
}
void MWShadowTechnique::ViewDependentData::releaseGLObjects(osg::State* state) const
@ -1400,7 +1401,7 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv)
if (numValidShadows>0)
{
decoratorStateGraph->setStateSet(selectStateSetForRenderingShadow(*vdd));
decoratorStateGraph->setStateSet(selectStateSetForRenderingShadow(*vdd, cv.getTraversalNumber()));
}
// OSG_NOTICE<<"End of shadow setup Projection matrix "<<*cv.getProjectionMatrix()<<std::endl;
@ -2974,17 +2975,17 @@ void MWShadowTechnique::cullShadowCastingScene(osgUtil::CullVisitor* cv, osg::Ca
return;
}
osg::StateSet* MWShadowTechnique::selectStateSetForRenderingShadow(ViewDependentData& vdd) const
osg::StateSet* MWShadowTechnique::selectStateSetForRenderingShadow(ViewDependentData& vdd, unsigned int traversalNumber) const
{
OSG_INFO<<" selectStateSetForRenderingShadow() "<<vdd.getStateSet()<<std::endl;
OSG_INFO<<" selectStateSetForRenderingShadow() "<<vdd.getStateSet(traversalNumber)<<std::endl;
osg::ref_ptr<osg::StateSet> stateset = vdd.getStateSet();
osg::ref_ptr<osg::StateSet> stateset = vdd.getStateSet(traversalNumber);
std::lock_guard<std::mutex> lock(_accessUniformsAndProgramMutex);
vdd.getStateSet()->clear();
stateset->clear();
vdd.getStateSet()->setTextureAttributeAndModes(0, _fallbackBaseTexture.get(), osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes(0, _fallbackBaseTexture.get(), osg::StateAttribute::ON);
for(Uniforms::const_iterator itr=_uniforms.begin();
itr!=_uniforms.end();
@ -3047,7 +3048,7 @@ osg::StateSet* MWShadowTechnique::selectStateSetForRenderingShadow(ViewDependent
stateset->setTextureMode(sd._textureUnit,GL_TEXTURE_GEN_Q,osg::StateAttribute::ON);
}
return vdd.getStateSet();
return stateset;
}
void MWShadowTechnique::resizeGLObjectBuffers(unsigned int /*maxSize*/)

@ -192,7 +192,7 @@ namespace SceneUtil {
ShadowDataList& getShadowDataList() { return _shadowDataList; }
osg::StateSet* getStateSet() { return _stateset.get(); }
osg::StateSet* getStateSet(unsigned int traversalNumber) { return _stateset[traversalNumber % 2].get(); }
virtual void releaseGLObjects(osg::State* = 0) const;
@ -201,7 +201,7 @@ namespace SceneUtil {
MWShadowTechnique* _viewDependentShadowMap;
osg::ref_ptr<osg::StateSet> _stateset;
std::array<osg::ref_ptr<osg::StateSet>, 2> _stateset;
LightDataList _lightDataList;
ShadowDataList _shadowDataList;
@ -231,7 +231,7 @@ namespace SceneUtil {
virtual void cullShadowCastingScene(osgUtil::CullVisitor* cv, osg::Camera* camera) const;
virtual osg::StateSet* selectStateSetForRenderingShadow(ViewDependentData& vdd) const;
virtual osg::StateSet* selectStateSetForRenderingShadow(ViewDependentData& vdd, unsigned int traversalNumber) const;
protected:
virtual ~MWShadowTechnique();

Loading…
Cancel
Save