mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 21:49:41 +00:00
Use the SceneManager's ShaderManager
This commit is contained in:
parent
0fc465da59
commit
e323b2fa7b
5 changed files with 7 additions and 30 deletions
|
@ -218,7 +218,7 @@ namespace MWRender
|
||||||
Settings::Manager::getBool("auto use terrain normal maps", "Shaders"),
|
Settings::Manager::getBool("auto use terrain normal maps", "Shaders"),
|
||||||
Settings::Manager::getString("terrain specular map pattern", "Shaders"), Settings::Manager::getBool("auto use terrain specular maps", "Shaders"));
|
Settings::Manager::getString("terrain specular map pattern", "Shaders"), Settings::Manager::getBool("auto use terrain specular maps", "Shaders"));
|
||||||
mTerrain.reset(new Terrain::TerrainGrid(sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(),
|
mTerrain.reset(new Terrain::TerrainGrid(sceneRoot, mResourceSystem, mViewer->getIncrementalCompileOperation(),
|
||||||
mTerrainStorage, Mask_Terrain, &mResourceSystem->getSceneManager()->getShaderManager()));
|
mTerrainStorage, Mask_Terrain));
|
||||||
|
|
||||||
mCamera.reset(new Camera(mViewer->getCamera()));
|
mCamera.reset(new Camera(mViewer->getCamera()));
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ ChunkManager::ChunkManager(Storage *storage, Resource::SceneManager *sceneMgr, T
|
||||||
, mStorage(storage)
|
, mStorage(storage)
|
||||||
, mSceneManager(sceneMgr)
|
, mSceneManager(sceneMgr)
|
||||||
, mTextureManager(textureManager)
|
, mTextureManager(textureManager)
|
||||||
, mShaderManager(NULL)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -66,11 +65,6 @@ osg::ref_ptr<osg::Node> ChunkManager::getChunk(float size, const osg::Vec2f &cen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkManager::setShaderManager(Shader::ShaderManager *shaderManager)
|
|
||||||
{
|
|
||||||
mShaderManager = shaderManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChunkManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const
|
void ChunkManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const
|
||||||
{
|
{
|
||||||
stats->setAttribute(frameNumber, "Terrain Chunk", mCache->getCacheSize());
|
stats->setAttribute(frameNumber, "Terrain Chunk", mCache->getCacheSize());
|
||||||
|
@ -165,8 +159,10 @@ osg::ref_ptr<osg::Node> ChunkManager::createChunk(float chunkSize, const osg::Ve
|
||||||
|
|
||||||
float blendmapScale = mStorage->getBlendmapScale(chunkSize);
|
float blendmapScale = mStorage->getBlendmapScale(chunkSize);
|
||||||
|
|
||||||
geometry->setPasses(createPasses(mShaderManager ? useShaders : false, mSceneManager->getForcePerPixelLighting(),
|
Shader::ShaderManager* shaderManager = &mSceneManager->getShaderManager();
|
||||||
mSceneManager->getClampLighting(), mShaderManager, layers, blendmapTextures, blendmapScale, blendmapScale));
|
|
||||||
|
geometry->setPasses(createPasses(useShaders, mSceneManager->getForcePerPixelLighting(),
|
||||||
|
mSceneManager->getClampLighting(), shaderManager, layers, blendmapTextures, blendmapScale, blendmapScale));
|
||||||
|
|
||||||
transform->addChild(geometry);
|
transform->addChild(geometry);
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,6 @@ namespace Resource
|
||||||
class SceneManager;
|
class SceneManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Shader
|
|
||||||
{
|
|
||||||
class ShaderManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Terrain
|
namespace Terrain
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -39,9 +34,6 @@ namespace Terrain
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> getChunk(float size, const osg::Vec2f& center);
|
osg::ref_ptr<osg::Node> getChunk(float size, const osg::Vec2f& center);
|
||||||
|
|
||||||
// Optional
|
|
||||||
void setShaderManager(Shader::ShaderManager* shaderManager);
|
|
||||||
|
|
||||||
virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const;
|
virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -50,7 +42,6 @@ namespace Terrain
|
||||||
Terrain::Storage* mStorage;
|
Terrain::Storage* mStorage;
|
||||||
Resource::SceneManager* mSceneManager;
|
Resource::SceneManager* mSceneManager;
|
||||||
TextureManager* mTextureManager;
|
TextureManager* mTextureManager;
|
||||||
Shader::ShaderManager* mShaderManager;
|
|
||||||
BufferCache mBufferCache;
|
BufferCache mBufferCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,16 +11,13 @@
|
||||||
namespace Terrain
|
namespace Terrain
|
||||||
{
|
{
|
||||||
|
|
||||||
TerrainGrid::TerrainGrid(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask, Shader::ShaderManager* shaderManager)
|
TerrainGrid::TerrainGrid(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask)
|
||||||
: Terrain::World(parent, resourceSystem, ico, storage, nodeMask)
|
: Terrain::World(parent, resourceSystem, ico, storage, nodeMask)
|
||||||
, mNumSplits(4)
|
, mNumSplits(4)
|
||||||
, mShaderManager(shaderManager)
|
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Material> material (new osg::Material);
|
osg::ref_ptr<osg::Material> material (new osg::Material);
|
||||||
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
|
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
|
||||||
mTerrainRoot->getOrCreateStateSet()->setAttributeAndModes(material, osg::StateAttribute::ON);
|
mTerrainRoot->getOrCreateStateSet()->setAttributeAndModes(material, osg::StateAttribute::ON);
|
||||||
|
|
||||||
mChunkManager->setShaderManager(mShaderManager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TerrainGrid::~TerrainGrid()
|
TerrainGrid::~TerrainGrid()
|
||||||
|
|
|
@ -7,11 +7,6 @@
|
||||||
|
|
||||||
#include "world.hpp"
|
#include "world.hpp"
|
||||||
|
|
||||||
namespace Shader
|
|
||||||
{
|
|
||||||
class ShaderManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace osg
|
namespace osg
|
||||||
{
|
{
|
||||||
class Texture2D;
|
class Texture2D;
|
||||||
|
@ -24,7 +19,7 @@ namespace Terrain
|
||||||
class TerrainGrid : public Terrain::World
|
class TerrainGrid : public Terrain::World
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TerrainGrid(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask, Shader::ShaderManager* shaderManager = NULL);
|
TerrainGrid(osg::Group* parent, Resource::ResourceSystem* resourceSystem, osgUtil::IncrementalCompileOperation* ico, Storage* storage, int nodeMask);
|
||||||
~TerrainGrid();
|
~TerrainGrid();
|
||||||
|
|
||||||
/// Load a terrain cell and store it in cache for later use.
|
/// Load a terrain cell and store it in cache for later use.
|
||||||
|
@ -50,8 +45,6 @@ namespace Terrain
|
||||||
|
|
||||||
typedef std::map<std::pair<int, int>, osg::ref_ptr<osg::Node> > Grid;
|
typedef std::map<std::pair<int, int>, osg::ref_ptr<osg::Node> > Grid;
|
||||||
Grid mGrid;
|
Grid mGrid;
|
||||||
|
|
||||||
Shader::ShaderManager* mShaderManager;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue