diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index 3db5dfc8cb..d9e6c1cf60 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -27,13 +27,12 @@ namespace MWRender TerrainMaterialGenerator::Profile* const activeProfile = mTerrainGlobals->getDefaultMaterialGenerator() ->getActiveProfile(); - TerrainMaterialGeneratorB::SM2Profile* matProfile = + mActiveProfile = static_cast(activeProfile); //The pixel error should be as high as possible without it being noticed - //as it governs how fast mesh quality decreases. 16 was just about Ok - //when tested at the small swamp pond in Seyda Neen - mTerrainGlobals->setMaxPixelError(16); + //as it governs how fast mesh quality decreases. + mTerrainGlobals->setMaxPixelError(8); mTerrainGlobals->setLayerBlendMapSize(32); mTerrainGlobals->setLightMapSize(256); @@ -47,12 +46,12 @@ namespace MWRender //this seemed the distance where it wasn't too noticeable mTerrainGlobals->setCompositeMapDistance(mWorldSize*2); - matProfile->setLightmapEnabled(false); - matProfile->setLayerSpecularMappingEnabled(false); - matProfile->setLayerNormalMappingEnabled(false); - matProfile->setLayerParallaxMappingEnabled(false); - matProfile->setReceiveDynamicShadowsEnabled(false); - matProfile->setGlobalColourMapEnabled(true); + mActiveProfile->setLightmapEnabled(false); + mActiveProfile->setLayerSpecularMappingEnabled(false); + mActiveProfile->setLayerNormalMappingEnabled(false); + mActiveProfile->setLayerParallaxMappingEnabled(false); + mActiveProfile->setReceiveDynamicShadowsEnabled(false); + mActiveProfile->setCompositeMapEnabled(false); mTerrainGroup = OGRE_NEW TerrainGroup(mgr, Terrain::ALIGN_X_Z, @@ -156,19 +155,25 @@ namespace MWRender numTextures, indexes); + // disable or enable global colour map (depends on available vertex colours) if ( store->land[1][1]->landData->usingColours ) - { + mActiveProfile->setGlobalColourMapEnabled(true); + else + mActiveProfile->setGlobalColourMapEnabled(false); + + if ( store->land[1][1]->landData->usingColours ) + { TexturePtr vertex = getVertexColours(store, x*(mLandSize-1), y*(mLandSize-1), mLandSize); //this is a hack to get around the fact that Ogre seems to - //corrupt the composite map leading to rendering errors - MaterialPtr mat = terrain->_getMaterial(); - mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() ); - mat = terrain->_getCompositeMapMaterial(); + //corrupt the global colour map leading to rendering errors + MaterialPtr mat = terrain->getMaterial(); mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() ); + //mat = terrain->_getCompositeMapMaterial(); + //mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() ); } } } diff --git a/apps/openmw/mwrender/terrain.hpp b/apps/openmw/mwrender/terrain.hpp index 6d98655400..397c0c473f 100644 --- a/apps/openmw/mwrender/terrain.hpp +++ b/apps/openmw/mwrender/terrain.hpp @@ -2,6 +2,7 @@ #define _GAME_RENDER_TERRAIN_H #include +#include "terrainmaterial.hpp" #include "../mwworld/ptr.hpp" @@ -34,6 +35,8 @@ namespace MWRender{ Ogre::TerrainGlobalOptions* mTerrainGlobals; Ogre::TerrainGroup* mTerrainGroup; + Ogre::TerrainMaterialGeneratorB::SM2Profile* mActiveProfile; + /** * The length in verticies of a single terrain block. */ diff --git a/apps/openmw/mwrender/terrainmaterial.cpp b/apps/openmw/mwrender/terrainmaterial.cpp index 0edc23a71b..67ebf45af6 100644 --- a/apps/openmw/mwrender/terrainmaterial.cpp +++ b/apps/openmw/mwrender/terrainmaterial.cpp @@ -134,7 +134,7 @@ namespace Ogre if (enabled != mGlobalColourMapEnabled) { mGlobalColourMapEnabled = enabled; - mParent->_markChanged(); + //mParent->_markChanged(); } } //--------------------------------------------------------------------- @@ -359,7 +359,7 @@ namespace Ogre tu->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); // global colour map - //if (terrain->getGlobalColourMapEnabled() && isGlobalColourMapEnabled()) + if (isGlobalColourMapEnabled()) { tu = pass->createTextureUnitState(""); tu->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); @@ -1004,7 +1004,7 @@ namespace Ogre "uniform sampler2D globalNormal : register(s" << currentSamplerIdx++ << ")\n"; - //if (terrain->getGlobalColourMapEnabled() && prof->isGlobalColourMapEnabled()) + if (prof->isGlobalColourMapEnabled()) { outStream << ", uniform sampler2D globalColourMap : register(s" << currentSamplerIdx++ << ")\n"; @@ -1299,7 +1299,7 @@ namespace Ogre } else { - //if (terrain->getGlobalColourMapEnabled() && prof->isGlobalColourMapEnabled()) + if (prof->isGlobalColourMapEnabled()) { // sample colour map and apply to diffuse outStream << " diffuse *= tex2D(globalColourMap, uv).rgb;\n";