1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

fixed terrain regions without vertexcolours, tweaked maxPixelError

This commit is contained in:
scrawl 2012-03-02 23:36:48 +01:00
parent 07a2e5a5be
commit b882c03adc
3 changed files with 27 additions and 16 deletions

View File

@ -27,13 +27,12 @@ namespace MWRender
Ogre::TerrainMaterialGenerator::Profile* const activeProfile = Ogre::TerrainMaterialGenerator::Profile* const activeProfile =
mTerrainGlobals->getDefaultMaterialGenerator() mTerrainGlobals->getDefaultMaterialGenerator()
->getActiveProfile(); ->getActiveProfile();
TerrainMaterialGeneratorB::SM2Profile* matProfile = mActiveProfile =
static_cast<TerrainMaterialGeneratorB::SM2Profile*>(activeProfile); static_cast<TerrainMaterialGeneratorB::SM2Profile*>(activeProfile);
//The pixel error should be as high as possible without it being noticed //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 //as it governs how fast mesh quality decreases.
//when tested at the small swamp pond in Seyda Neen mTerrainGlobals->setMaxPixelError(8);
mTerrainGlobals->setMaxPixelError(16);
mTerrainGlobals->setLayerBlendMapSize(32); mTerrainGlobals->setLayerBlendMapSize(32);
mTerrainGlobals->setLightMapSize(256); mTerrainGlobals->setLightMapSize(256);
@ -47,12 +46,11 @@ namespace MWRender
//this seemed the distance where it wasn't too noticeable //this seemed the distance where it wasn't too noticeable
mTerrainGlobals->setCompositeMapDistance(mWorldSize*2); mTerrainGlobals->setCompositeMapDistance(mWorldSize*2);
matProfile->setLightmapEnabled(false); mActiveProfile->setLightmapEnabled(false);
matProfile->setLayerSpecularMappingEnabled(false); mActiveProfile->setLayerSpecularMappingEnabled(false);
matProfile->setLayerNormalMappingEnabled(false); mActiveProfile->setLayerNormalMappingEnabled(false);
matProfile->setLayerParallaxMappingEnabled(false); mActiveProfile->setLayerParallaxMappingEnabled(false);
matProfile->setReceiveDynamicShadowsEnabled(false); mActiveProfile->setReceiveDynamicShadowsEnabled(false);
matProfile->setGlobalColourMapEnabled(true);
mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mgr, mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mgr,
Ogre::Terrain::ALIGN_X_Z, Ogre::Terrain::ALIGN_X_Z,
@ -156,15 +154,25 @@ namespace MWRender
numTextures, numTextures,
indexes); indexes);
// disable or enable global colour map (depends on available vertex colours)
if ( store->land[1][1]->landData->usingColours ) if ( store->land[1][1]->landData->usingColours )
{ mActiveProfile->setGlobalColourMapEnabled(true);
else
mActiveProfile->setGlobalColourMapEnabled(false);
/// \todo are we possibly generating the materials twice?
mActiveProfile->generate(terrain);
mActiveProfile->generateForCompositeMap(terrain);
if ( store->land[1][1]->landData->usingColours )
{
Ogre::TexturePtr vertex = getVertexColours(store, Ogre::TexturePtr vertex = getVertexColours(store,
x*(mLandSize-1), x*(mLandSize-1),
y*(mLandSize-1), y*(mLandSize-1),
mLandSize); mLandSize);
//this is a hack to get around the fact that Ogre seems to //this is a hack to get around the fact that Ogre seems to
//corrupt the composite map leading to rendering errors //corrupt the global colour map leading to rendering errors
MaterialPtr mat = terrain->_getMaterial(); MaterialPtr mat = terrain->_getMaterial();
mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() ); mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( vertex->getName() );
mat = terrain->_getCompositeMapMaterial(); mat = terrain->_getCompositeMapMaterial();

View File

@ -2,6 +2,7 @@
#define _GAME_RENDER_TERRAIN_H #define _GAME_RENDER_TERRAIN_H
#include <OgreTerrain.h> #include <OgreTerrain.h>
#include "terrainmaterial.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
@ -34,6 +35,8 @@ namespace MWRender{
Ogre::TerrainGlobalOptions* mTerrainGlobals; Ogre::TerrainGlobalOptions* mTerrainGlobals;
Ogre::TerrainGroup* mTerrainGroup; Ogre::TerrainGroup* mTerrainGroup;
Ogre::TerrainMaterialGeneratorB::SM2Profile* mActiveProfile;
/** /**
* The length in verticies of a single terrain block. * The length in verticies of a single terrain block.
*/ */

View File

@ -134,7 +134,7 @@ namespace Ogre
if (enabled != mGlobalColourMapEnabled) if (enabled != mGlobalColourMapEnabled)
{ {
mGlobalColourMapEnabled = enabled; mGlobalColourMapEnabled = enabled;
mParent->_markChanged(); //mParent->_markChanged();
} }
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
@ -359,7 +359,7 @@ namespace Ogre
tu->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); tu->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
// global colour map // global colour map
//if (terrain->getGlobalColourMapEnabled() && isGlobalColourMapEnabled()) if (isGlobalColourMapEnabled())
{ {
tu = pass->createTextureUnitState(""); tu = pass->createTextureUnitState("");
tu->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); tu->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
@ -1004,7 +1004,7 @@ namespace Ogre
"uniform sampler2D globalNormal : register(s" << currentSamplerIdx++ << ")\n"; "uniform sampler2D globalNormal : register(s" << currentSamplerIdx++ << ")\n";
//if (terrain->getGlobalColourMapEnabled() && prof->isGlobalColourMapEnabled()) if (prof->isGlobalColourMapEnabled())
{ {
outStream << ", uniform sampler2D globalColourMap : register(s" outStream << ", uniform sampler2D globalColourMap : register(s"
<< currentSamplerIdx++ << ")\n"; << currentSamplerIdx++ << ")\n";
@ -1299,7 +1299,7 @@ namespace Ogre
} }
else else
{ {
//if (terrain->getGlobalColourMapEnabled() && prof->isGlobalColourMapEnabled()) if (prof->isGlobalColourMapEnabled())
{ {
// sample colour map and apply to diffuse // sample colour map and apply to diffuse
outStream << " diffuse *= tex2D(globalColourMap, uv).rgb;\n"; outStream << " diffuse *= tex2D(globalColourMap, uv).rgb;\n";