diff --git a/components/shader/shadervisitor.cpp b/components/shader/shadervisitor.cpp index a734151eb..b68d419a3 100644 --- a/components/shader/shadervisitor.cpp +++ b/components/shader/shadervisitor.cpp @@ -318,9 +318,9 @@ namespace Shader const ShaderRequirements& reqs = mRequirements.back(); bool useShader = reqs.mShaderRequired || mForceShaders; - bool generateTangents = reqs.mTexStageRequiringTangents != -1 && mAllowedToModifyStateSets; + bool generateTangents = reqs.mTexStageRequiringTangents != -1; - if (useShader || generateTangents) + if (mAllowedToModifyStateSets && (useShader || generateTangents)) { osg::ref_ptr sourceGeometry = &geometry; SceneUtil::RigGeometry* rig = dynamic_cast(&geometry); @@ -329,16 +329,13 @@ namespace Shader bool requiresSetGeometry = false; - if (mAllowedToModifyStateSets) + // make sure that all UV sets are there + for (std::map::const_iterator it = reqs.mTextures.begin(); it != reqs.mTextures.end(); ++it) { - // make sure that all UV sets are there - for (std::map::const_iterator it = reqs.mTextures.begin(); it != reqs.mTextures.end(); ++it) + if (sourceGeometry->getTexCoordArray(it->first) == NULL) { - if (sourceGeometry->getTexCoordArray(it->first) == NULL) - { - sourceGeometry->setTexCoordArray(it->first, sourceGeometry->getTexCoordArray(0)); - requiresSetGeometry = true; - } + sourceGeometry->setTexCoordArray(it->first, sourceGeometry->getTexCoordArray(0)); + requiresSetGeometry = true; } }