コード例 #1
0
void ShadowManager::updatePSSM(Ogre::Terrain* terrain)
{
	if (!mPSSMSetup.get())  return;

	Ogre::TerrainMaterialGeneratorA::SM2Profile *matProfile  = 0;
	if (Ogre::TerrainGlobalOptions::getSingletonPtr())
	{
		matProfile = static_cast<Ogre::TerrainMaterialGeneratorA::SM2Profile*>(Ogre::TerrainGlobalOptions::getSingleton().getDefaultMaterialGenerator()->getActiveProfile());
		matProfile->setReceiveDynamicShadowsEnabled(true);
		matProfile->setReceiveDynamicShadowsLowLod(true);
		matProfile->setGlobalColourMapEnabled(false);
	}


	Ogre::PSSMShadowCameraSetup* pssmSetup = static_cast<Ogre::PSSMShadowCameraSetup*>(mPSSMSetup.get());
	const Ogre::PSSMShadowCameraSetup::SplitPointList& splitPointList = pssmSetup->getSplitPoints();

	Ogre::Vector4 splitPoints;
	for (size_t i = 0; i < /*3*/splitPointList.size(); ++i)
		splitPoints[i] = splitPointList[i];

	// TODO: fix this
	//setMaterialSplitPoints("road", splitPoints);
	//setMaterialSplitPoints("road2", splitPoints);


	if (matProfile && terrain)
	{
		matProfile->generateForCompositeMap(terrain);
		matProfile->setReceiveDynamicShadowsDepth(mDepthShadows);
		matProfile->setReceiveDynamicShadowsPSSM(static_cast<Ogre::PSSMShadowCameraSetup*>(mPSSMSetup.get()));
	}
}
コード例 #2
0
ファイル: Terrain.cpp プロジェクト: JOSE89/DamnedSunset
	void CTerrain::configureShadows()
	{
		Ogre::TerrainMaterialGeneratorA::SM2Profile* matProfile = 
			static_cast<Ogre::TerrainMaterialGeneratorA::SM2Profile*>(_terrainGlobals->getDefaultMaterialGenerator()->getActiveProfile());
		matProfile->setReceiveDynamicShadowsEnabled(true);
		matProfile->setReceiveDynamicShadowsLowLod(true);
		
		matProfile->setReceiveDynamicShadowsDepth(false);
		//matProfile->setReceiveDynamicShadowsPSSM(static_cast<Ogre::PSSMShadowCameraSetup*>(mPSSMSetup.get()));

		//addTextureShadowDebugOverlay(TL_RIGHT, 3);
	}
コード例 #3
0
void ShadowManager::updatePSSM(Ogre::Terrain* terrain)
{
	if (!PSSM_Shadows.mPSSMSetup.get())  return;

	Ogre::TerrainMaterialGeneratorA::SM2Profile *matProfile = 0;
	if (Ogre::TerrainGlobalOptions::getSingletonPtr())
	{
		matProfile = static_cast<Ogre::TerrainMaterialGeneratorA::SM2Profile*>(Ogre::TerrainGlobalOptions::getSingleton().getDefaultMaterialGenerator()->getActiveProfile());
		matProfile->setReceiveDynamicShadowsEnabled(true);
		matProfile->setReceiveDynamicShadowsLowLod(true);
		matProfile->setGlobalColourMapEnabled(true);
	}


	Ogre::PSSMShadowCameraSetup* pssmSetup = static_cast<Ogre::PSSMShadowCameraSetup*>(PSSM_Shadows.mPSSMSetup.get());
	Ogre::PSSMShadowCameraSetup::SplitPointList splitPointList = pssmSetup->getSplitPoints();

	
	splitPointList[0] = 1.0;
	splitPointList[1] = 95.0;
	splitPointList[2] = 255.0;
	splitPointList[3] = 512.0;
	pssmSetup->setSplitPoints(splitPointList);
	
	
	Ogre::Vector4 splitPoints;
	for (int i = 0; i < PSSM_Shadows.ShadowsTextureNum; ++i)
		splitPoints[i] = splitPointList[i];

	MaterialPtr mat = MaterialManager::getSingleton().getByName("RoR/Managed_Mats/Base");
	mat->getTechnique("ShadowTechnique")->getPass(0)->getFragmentProgramParameters()->setNamedConstant("pssmSplitPoints", splitPoints);

	// TODO: fix this
/*	setMaterialSplitPoints("road", splitPoints);
	setMaterialSplitPoints("road2", splitPoints);
	*/

	if (matProfile && terrain)
	{
		matProfile->generateForCompositeMap(terrain);
		matProfile->setReceiveDynamicShadowsDepth(PSSM_Shadows.mDepthShadows);
		matProfile->setReceiveDynamicShadowsPSSM(static_cast<Ogre::PSSMShadowCameraSetup*>(PSSM_Shadows.mPSSMSetup.get()));
	}
}