void configureTerrainDefaults( Light* l )
  {
    // Configure global
    mTerrainGlobals->setMaxPixelError( 8 );
    // testing composite map
    mTerrainGlobals->setCompositeMapDistance( 3000 );
    //mTerrainGlobals->setUseRayBoxDistanceCalculation(true);
    //mTerrainGlobals->getDefaultMaterialGenerator()->setDebugLevel(1);
    //mTerrainGlobals->setLightMapSize(256);
#if OGRE_NO_GLES3_SUPPORT == 1
        // Disable the lightmap for OpenGL ES 2.0. The minimum number of samplers allowed is 8(as opposed to 16 on desktop).
        // Otherwise we will run over the limit by just one. The minimum was raised to 16 in GL ES 3.0.
    if( Ogre::Root::getSingletonPtr()->getRenderSystem()->getName().find( "OpenGL ES 2" ) != String::npos )
    {
      TerrainMaterialGeneratorA::SM2Profile* matProfile =
        static_cast<TerrainMaterialGeneratorA::SM2Profile*>(mTerrainGlobals->getDefaultMaterialGenerator()->getActiveProfile());
      matProfile->setLightmapEnabled( false );
    }
#endif
    // Important to set these so that the terrain knows what to use for derived (non-realtime) data
    mTerrainGlobals->setLightMapDirection( l->getDerivedDirection() );
    mTerrainGlobals->setCompositeMapAmbient( mSceneMgr->getAmbientLight() );
    //mTerrainGlobals->setCompositeMapAmbient(ColourValue::Red);
    mTerrainGlobals->setCompositeMapDiffuse( l->getDiffuseColour() );

    // Configure default import settings for if we use imported image
    Terrain::ImportData& defaultimp = mTerrainGroup->getDefaultImportSettings();
    defaultimp.terrainSize = TERRAIN_SIZE;
    defaultimp.worldSize = TERRAIN_WORLD_SIZE;
    defaultimp.inputScale = 600;
    defaultimp.minBatchSize = 33;
    defaultimp.maxBatchSize = 65;
    // textures
    defaultimp.layerList.resize( 3 );
    defaultimp.layerList[0].worldSize = 100;
    defaultimp.layerList[0].textureNames.push_back( "dirt_grayrocky_diffusespecular.dds" );
    defaultimp.layerList[0].textureNames.push_back( "dirt_grayrocky_normalheight.dds" );
    defaultimp.layerList[1].worldSize = 30;
    defaultimp.layerList[1].textureNames.push_back( "grass_green-01_diffusespecular.dds" );
    defaultimp.layerList[1].textureNames.push_back( "grass_green-01_normalheight.dds" );
    defaultimp.layerList[2].worldSize = 200;
    defaultimp.layerList[2].textureNames.push_back( "growth_weirdfungus-03_diffusespecular.dds" );
    defaultimp.layerList[2].textureNames.push_back( "growth_weirdfungus-03_normalheight.dds" );
  }
Exemple #2
0
	void COgreManager::SetRenderingStyle()
	{
#ifdef FORWARD_RENDERING
		RenderManager.m_pDS->setActive(false);
		Ogre::TerrainGlobalOptions::getSingleton().setDefaultMaterialGenerator(
			Ogre::TerrainMaterialGeneratorPtr(new Ogre::TerrainMaterialGeneratorA));
		TerrainMaterialGeneratorA::SM2Profile* matProfile = static_cast<TerrainMaterialGeneratorA::SM2Profile*>(
			TerrainGlobalOptions::getSingleton().getDefaultMaterialGenerator()->getActiveProfile());
		matProfile->setCompositeMapEnabled(false);

#else	//deferred shading
		RenderManager.m_pDS->setActive(true);
		Ogre::TerrainGlobalOptions::getSingleton().setDefaultMaterialGenerator(
			Ogre::TerrainMaterialGeneratorPtr(new Kratos::TerrainMaterialGeneratorD));
		TerrainMaterialGeneratorD::SM2Profile* matProfile = static_cast<TerrainMaterialGeneratorD::SM2Profile*>(
			TerrainGlobalOptions::getSingleton().getDefaultMaterialGenerator()->getActiveProfile());
		matProfile->setCompositeMapEnabled(false);
#endif
	}
void TerrainGeometryManager::configureTerrainDefaults()
{
	OGRE_NEW TerrainGlobalOptions();

	Light *light = gEnv->terrainManager->getMainLight();
	TerrainGlobalOptions *terrainOptions = TerrainGlobalOptions::getSingletonPtr();
	// Configure global
	terrainOptions->setMaxPixelError(IOPT("MaxPixelError", 5));

	// Important to set these so that the terrain knows what to use for derived (non-realtime) data
	if (light)
	{
		terrainOptions->setLightMapDirection(light->getDerivedDirection());
		terrainOptions->setCompositeMapDiffuse(light->getDiffuseColour());
	}
	terrainOptions->setCompositeMapAmbient(gEnv->sceneManager->getAmbientLight());

	// Configure default import settings for if we use imported image
	Ogre::Terrain::ImportData& defaultimp = mTerrainGroup->getDefaultImportSettings();
	defaultimp.terrainSize  = terrainSize; // the heightmap size
	defaultimp.worldSize    = worldSize; // this is the scaled up size, like 12km
	defaultimp.inputScale   = mapsizey;
	defaultimp.minBatchSize = IOPT("minBatchSize", 33);
	defaultimp.maxBatchSize = IOPT("maxBatchSize", 65);

	// optimizations
	TerrainMaterialGeneratorA::SM2Profile* matProfile = static_cast<TerrainMaterialGeneratorA::SM2Profile*>(terrainOptions->getDefaultMaterialGenerator()->getActiveProfile());
	if (matProfile)
	{
		matProfile->setLightmapEnabled(BOPT("LightmapEnabled", false));
		matProfile->setLayerNormalMappingEnabled(BOPT("NormalMappingEnabled", false));
		matProfile->setLayerSpecularMappingEnabled(BOPT("SpecularMappingEnabled", false));
		matProfile->setLayerParallaxMappingEnabled(BOPT("ParallaxMappingEnabled", false));
		matProfile->setGlobalColourMapEnabled(BOPT("GlobalColourMapEnabled", false));
		matProfile->setReceiveDynamicShadowsDepth(BOPT("ReceiveDynamicShadowsDepth", true));
	}

	terrainOptions->setLayerBlendMapSize(IOPT("LayerBlendMapSize", 1024));
	terrainOptions->setCompositeMapSize(IOPT("CompositeMapSize", 1024));
	terrainOptions->setCompositeMapDistance(IOPT("CompositeMapDistance", 4000));
	terrainOptions->setSkirtSize(IOPT("SkirtSize", 30));
	terrainOptions->setLightMapSize(IOPT("LightMapSize", 1024));
	terrainOptions->setCastsDynamicShadows(BOPT("CastsDynamicShadows", true));

	terrainOptions->setUseRayBoxDistanceCalculation(false);

	// load layer basics now
	loadLayers(0, 0, 0);
}
  void configureShadows( bool enabled, bool depthShadows )
  {
    TerrainMaterialGeneratorA::SM2Profile* matProfile =
      static_cast<TerrainMaterialGeneratorA::SM2Profile*>(mTerrainGlobals->getDefaultMaterialGenerator()->getActiveProfile());
    matProfile->setReceiveDynamicShadowsEnabled( enabled );
#ifdef SHADOWS_IN_LOW_LOD_MATERIAL
    matProfile->setReceiveDynamicShadowsLowLod( true );
#else
    matProfile->setReceiveDynamicShadowsLowLod( false );
#endif
    // Default materials
    for( EntityList::iterator i = mHouseList.begin(); i != mHouseList.end(); ++i )
    {
      (*i)->setMaterialName( "Examples/TudorHouse" );
    }
    if( enabled )
    {// General scene setup
      mSceneMgr->setShadowTechnique( SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED );
      mSceneMgr->setShadowFarDistance( 3000 );

      // 3 textures per directional light (PSSM)
      mSceneMgr->setShadowTextureCountPerLightType( Ogre::Light::LT_DIRECTIONAL, 3 );
      if( mPSSMSetup.isNull() )
      {// shadow camera setup
        PSSMShadowCameraSetup* pssmSetup = new PSSMShadowCameraSetup();
        pssmSetup->setSplitPadding( mCamera->getNearClipDistance() );
        pssmSetup->calculateSplitPoints( 3, mCamera->getNearClipDistance(), mSceneMgr->getShadowFarDistance() );
        pssmSetup->setOptimalAdjustFactor( 0, 2 );
        pssmSetup->setOptimalAdjustFactor( 1, 1 );
        pssmSetup->setOptimalAdjustFactor( 2, 0.5 );

        mPSSMSetup.bind( pssmSetup );
      }
      mSceneMgr->setShadowCameraSetup( mPSSMSetup );
      if( depthShadows )
      {
        mSceneMgr->setShadowTextureCount( 3 );
        mSceneMgr->setShadowTextureConfig( 0, 2048, 2048, PF_FLOAT32_R );
        mSceneMgr->setShadowTextureConfig( 1, 1024, 1024, PF_FLOAT32_R );
        mSceneMgr->setShadowTextureConfig( 2, 1024, 1024, PF_FLOAT32_R );
        mSceneMgr->setShadowTextureSelfShadow( true );
        mSceneMgr->setShadowCasterRenderBackFaces( true );

        MaterialPtr houseMat = buildDepthShadowMaterial( "fw12b.jpg" );
        for( EntityList::iterator i = mHouseList.begin(); i != mHouseList.end(); ++i )
        {
          (*i)->setMaterial( houseMat );
        }
      }
      else
      {
        mSceneMgr->setShadowTextureCount( 3 );
        mSceneMgr->setShadowTextureConfig( 0, 2048, 2048, PF_X8B8G8R8 );
        mSceneMgr->setShadowTextureConfig( 1, 1024, 1024, PF_X8B8G8R8 );
        mSceneMgr->setShadowTextureConfig( 2, 1024, 1024, PF_X8B8G8R8 );
        mSceneMgr->setShadowTextureSelfShadow( false );
        mSceneMgr->setShadowCasterRenderBackFaces( false );
        mSceneMgr->setShadowTextureCasterMaterial( StringUtil::BLANK );
      }
      matProfile->setReceiveDynamicShadowsDepth( depthShadows );
      matProfile->setReceiveDynamicShadowsPSSM( static_cast<PSSMShadowCameraSetup*>(mPSSMSetup.get()) );
      //addTextureShadowDebugOverlay(TL_RIGHT, 3);
    }
    else
    {
      mSceneMgr->setShadowTechnique( SHADOWTYPE_NONE );
    }
  }