diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index b87446351..571ea6d0d 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -242,9 +242,9 @@ namespace Resource return mForceShaders; } - void SceneManager::recreateShaders(osg::ref_ptr node) + void SceneManager::recreateShaders(osg::ref_ptr node, const std::string& shaderPrefix) { - osg::ref_ptr shaderVisitor(createShaderVisitor()); + osg::ref_ptr shaderVisitor(createShaderVisitor(shaderPrefix)); shaderVisitor->setAllowedToModifyStateSets(false); node->accept(*shaderVisitor); } @@ -761,9 +761,9 @@ namespace Resource stats->setAttribute(frameNumber, "Node Instance", mInstanceCache->getCacheSize()); } - Shader::ShaderVisitor *SceneManager::createShaderVisitor() + Shader::ShaderVisitor *SceneManager::createShaderVisitor(const std::string& shaderPrefix) { - Shader::ShaderVisitor* shaderVisitor = new Shader::ShaderVisitor(*mShaderManager.get(), *mImageManager, "objects_vertex.glsl", "objects_fragment.glsl"); + Shader::ShaderVisitor* shaderVisitor = new Shader::ShaderVisitor(*mShaderManager.get(), *mImageManager, shaderPrefix+"_vertex.glsl", shaderPrefix+"_fragment.glsl"); shaderVisitor->setForceShaders(mForceShaders); shaderVisitor->setAutoUseNormalMaps(mAutoUseNormalMaps); shaderVisitor->setNormalMapPattern(mNormalMapPattern); diff --git a/components/resource/scenemanager.hpp b/components/resource/scenemanager.hpp index 3a72caf6a..0ee32a9b7 100644 --- a/components/resource/scenemanager.hpp +++ b/components/resource/scenemanager.hpp @@ -51,7 +51,7 @@ namespace Resource Shader::ShaderManager& getShaderManager(); /// Re-create shaders for this node, need to call this if texture stages or vertex color mode have changed. - void recreateShaders(osg::ref_ptr node); + void recreateShaders(osg::ref_ptr node, const std::string& shaderPrefix = "objects"); /// @see ShaderVisitor::setForceShaders void setForceShaders(bool force); @@ -146,7 +146,7 @@ namespace Resource private: - Shader::ShaderVisitor* createShaderVisitor(); + Shader::ShaderVisitor* createShaderVisitor(const std::string& shaderPrefix = "objects"); std::unique_ptr mShaderManager; bool mForceShaders;