Fix incomplete settings in recreateShaders()

new-script-api
scrawl 7 years ago
parent 03554b2f4b
commit 136ef1f738

@ -244,12 +244,9 @@ namespace Resource
void SceneManager::recreateShaders(osg::ref_ptr<osg::Node> node)
{
Shader::ShaderVisitor shaderVisitor(*mShaderManager.get(), *mImageManager, "objects_vertex.glsl", "objects_fragment.glsl");
shaderVisitor.setForceShaders(mForceShaders);
shaderVisitor.setClampLighting(mClampLighting);
shaderVisitor.setForcePerPixelLighting(mForcePerPixelLighting);
shaderVisitor.setAllowedToModifyStateSets(false);
node->accept(shaderVisitor);
osg::ref_ptr<Shader::ShaderVisitor> shaderVisitor(createShaderVisitor());
shaderVisitor->setAllowedToModifyStateSets(false);
node->accept(*shaderVisitor);
}
void SceneManager::setClampLighting(bool clamp)
@ -516,16 +513,8 @@ namespace Resource
SetFilterSettingsControllerVisitor setFilterSettingsControllerVisitor(mMinFilter, mMagFilter, mMaxAnisotropy);
loaded->accept(setFilterSettingsControllerVisitor);
Shader::ShaderVisitor shaderVisitor(*mShaderManager.get(), *mImageManager, "objects_vertex.glsl", "objects_fragment.glsl");
shaderVisitor.setForceShaders(mForceShaders);
shaderVisitor.setClampLighting(mClampLighting);
shaderVisitor.setForcePerPixelLighting(mForcePerPixelLighting);
shaderVisitor.setAutoUseNormalMaps(mAutoUseNormalMaps);
shaderVisitor.setNormalMapPattern(mNormalMapPattern);
shaderVisitor.setNormalHeightMapPattern(mNormalHeightMapPattern);
shaderVisitor.setAutoUseSpecularMaps(mAutoUseSpecularMaps);
shaderVisitor.setSpecularMapPattern(mSpecularMapPattern);
loaded->accept(shaderVisitor);
osg::ref_ptr<Shader::ShaderVisitor> shaderVisitor (createShaderVisitor());
loaded->accept(*shaderVisitor);
// share state
// do this before optimizing so the optimizer will be able to combine nodes more aggressively
@ -748,4 +737,18 @@ namespace Resource
stats->setAttribute(frameNumber, "Node Instance", mInstanceCache->getCacheSize());
}
Shader::ShaderVisitor *SceneManager::createShaderVisitor()
{
Shader::ShaderVisitor* shaderVisitor = new Shader::ShaderVisitor(*mShaderManager.get(), *mImageManager, "objects_vertex.glsl", "objects_fragment.glsl");
shaderVisitor->setForceShaders(mForceShaders);
shaderVisitor->setClampLighting(mClampLighting);
shaderVisitor->setForcePerPixelLighting(mForcePerPixelLighting);
shaderVisitor->setAutoUseNormalMaps(mAutoUseNormalMaps);
shaderVisitor->setNormalMapPattern(mNormalMapPattern);
shaderVisitor->setNormalHeightMapPattern(mNormalHeightMapPattern);
shaderVisitor->setAutoUseSpecularMaps(mAutoUseSpecularMaps);
shaderVisitor->setSpecularMapPattern(mSpecularMapPattern);
return shaderVisitor;
}
}

@ -31,6 +31,7 @@ namespace osgDB
namespace Shader
{
class ShaderManager;
class ShaderVisitor;
}
namespace Resource
@ -149,6 +150,8 @@ namespace Resource
private:
Shader::ShaderVisitor* createShaderVisitor();
std::unique_ptr<Shader::ShaderManager> mShaderManager;
bool mForceShaders;
bool mClampLighting;

Loading…
Cancel
Save