@ -280,10 +280,12 @@ namespace Shader
osg : : StateSet : : AttributeList removedAttributes ;
osg : : StateSet : : AttributeList removedAttributes ;
if ( osg : : ref_ptr < osg : : StateSet > removedState = getRemovedState ( * stateset ) )
if ( osg : : ref_ptr < osg : : StateSet > removedState = getRemovedState ( * stateset ) )
removedAttributes = removedState - > getAttributeList ( ) ;
removedAttributes = removedState - > getAttributeList ( ) ;
for ( const auto & attributeMap : { attributes , removedAttributes } )
for ( const auto * attributeMap : std : : initializer_list < const osg : : StateSet : : AttributeList * > { & attributes , & removedAttributes } )
{
{
for ( osg : : StateSet : : AttributeList : : const_iterator it = attributeMap . begin ( ) ; it ! = attributeMap . end ( ) ; + + it )
for ( osg : : StateSet : : AttributeList : : const_iterator it = attributeMap - > begin ( ) ; it ! = attributeMap - > end ( ) ; + + it )
{
{
if ( attributeMap ! = & removedAttributes & & removedAttributes . count ( it - > first ) )
continue ;
if ( it - > first . first = = osg : : StateAttribute : : MATERIAL )
if ( it - > first . first = = osg : : StateAttribute : : MATERIAL )
{
{
// This should probably be moved out of ShaderRequirements and be applied directly now it's a uniform instead of a define
// This should probably be moved out of ShaderRequirements and be applied directly now it's a uniform instead of a define
@ -405,9 +407,12 @@ namespace Shader
{
{
writableStateSet - > addUniform ( new osg : : Uniform ( " alphaRef " , reqs . mAlphaRef ) ) ;
writableStateSet - > addUniform ( new osg : : Uniform ( " alphaRef " , reqs . mAlphaRef ) ) ;
const auto * alphaFunc = writableStateSet - > getAttributePair ( osg : : StateAttribute : : ALPHAFUNC ) ;
if ( ! removedState - > getAttributePair ( osg : : StateAttribute : : ALPHAFUNC ) )
if ( alphaFunc )
{
removedState - > setAttribute ( alphaFunc - > first , alphaFunc - > second ) ;
const auto * alphaFunc = writableStateSet - > getAttributePair ( osg : : StateAttribute : : ALPHAFUNC ) ;
if ( alphaFunc )
removedState - > setAttribute ( alphaFunc - > first , alphaFunc - > second ) ;
}
// This prevents redundant glAlphaFunc calls while letting the shadows bin still see the test
// This prevents redundant glAlphaFunc calls while letting the shadows bin still see the test
writableStateSet - > setAttribute ( RemovedAlphaFunc : : getInstance ( reqs . mAlphaFunc ) , osg : : StateAttribute : : ON | osg : : StateAttribute : : OVERRIDE ) ;
writableStateSet - > setAttribute ( RemovedAlphaFunc : : getInstance ( reqs . mAlphaFunc ) , osg : : StateAttribute : : ON | osg : : StateAttribute : : OVERRIDE ) ;