SO3Engine
|
SO3DeferredShadowManager.cpp
Go to the documentation of this file.
29template<> SO3::SDeferredShadowManager* Ogre::Singleton<SO3::SDeferredShadowManager>::msSingleton = 0;
61 deferredShadowStandardTextureName = std::string(SO3_DEFERRED_SHADOWS_SCHEME_NAME) + std::string(SO3_DEFERRED_SHADOWS_STANDARD_BASE_NAME) + std::string(SO3_DEFERRED_SHADOWS_TEXTURE_NAME);
62 deferredShadowStandardCameraName = std::string(SO3_DEFERRED_SHADOWS_SCHEME_NAME) + std::string(SO3_DEFERRED_SHADOWS_STANDARD_BASE_NAME) + std::string(SO3_DEFERRED_SHADOWS_CAMERA_NAME);
63 deferredShadowStandardMaterialName = std::string(SO3_DEFERRED_SHADOWS_SCHEME_NAME) + std::string(SO3_DEFERRED_SHADOWS_STANDARD_BASE_NAME) + std::string(SO3_DEFERRED_SHADOWS_MATERIAL_NAME);
64 deferredShadowCubicTextureName = std::string(SO3_DEFERRED_SHADOWS_SCHEME_NAME) + std::string(SO3_DEFERRED_SHADOWS_CUBIC_BASE_NAME) + std::string(SO3_DEFERRED_SHADOWS_TEXTURE_NAME);
65 deferredShadowCubicCameraName = std::string(SO3_DEFERRED_SHADOWS_SCHEME_NAME) + std::string(SO3_DEFERRED_SHADOWS_CUBIC_BASE_NAME) + std::string(SO3_DEFERRED_SHADOWS_CAMERA_NAME);
66 deferredShadowCubicMaterialName = std::string(SO3_DEFERRED_SHADOWS_SCHEME_NAME) + std::string(SO3_DEFERRED_SHADOWS_CUBIC_BASE_NAME) + std::string(SO3_DEFERRED_SHADOWS_MATERIAL_NAME);
106 OgreSceneManagerList::iterator ogreSceneManagerSearched = ogreSceneManagerList.find(targetScene);
108 SO3_EXCEPT(SExceptionItemIdentity, "Trying to register an already registered scene manager!", "SDeferredShadowManager::RegisterSceneManager", true);
115 // Create shadow standard texture camera. Camera names are handled by each scene, so no worries about duplicate items
116 Ogre::Camera* ogreStandardShadowCamera = targetScene->createCamera(deferredShadowStandardCameraName);
118 standardTextureCameraByScene.insert(StandardTextureCameraByScene::value_type(targetScene, ogreStandardShadowCamera));
124 Ogre::Camera* ogreCubicShadowCamera = targetScene->createCamera(deferredShadowCubicCameraName + boost::lexical_cast<std::string, int>(cpt));
137 OgreSceneManagerList::iterator ogreSceneManagerSearched = ogreSceneManagerList.find(existingScene);
139 SO3_EXCEPT(SExceptionItemNotFound, "Trying to unregister a scene manager that is not registered!", "SDeferredShadowManager::UnregisterSceneManager", true);
236 shadowStandardTexture = Ogre::TextureManager::getSingleton().createManual(deferredShadowStandardTextureName,
251 shadowStandardMaterial = Ogre::MaterialManager::getSingleton().create(deferredShadowStandardMaterialName, Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
256 Ogre::TextureUnitState* texUnit = ogreShadowPass->createTextureUnitState(deferredShadowStandardTextureName);
271 shadowCubicTexture = Ogre::TextureManager::getSingleton().createManual(deferredShadowCubicTextureName,
286 shadowCubicMaterial = Ogre::MaterialManager::getSingleton().create(deferredShadowCubicMaterialName, Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
291 Ogre::TextureUnitState* texUnit = ogreShadowPass->createTextureUnitState(deferredShadowCubicTextureName);
308 Ogre::RenderTarget* ogreShadowRenderTarget = shadowStandardTexture->getBuffer()->getRenderTarget();
334 Ogre::RenderTarget* ogreShadowRenderTarget = shadowCubicTexture->getBuffer(cpt)->getRenderTarget();
353Ogre::TexturePtr& SDeferredShadowManager::PrepareShadowTexture(Ogre::Camera* ogreCamera, Ogre::Viewport* ogreViewport, const Ogre::Light* light, Ogre::Pass* ogrePass)
357 OgreSceneManagerList::iterator ogreSceneManagerSearched = ogreSceneManagerList.find(ogreTargetScene);
359 SO3_EXCEPT(SExceptionItemNotFound, "Can not prepare shadow texture for the scenemanager \""+ ogreTargetScene->getName() +"\", as it seems that it does not use deferred rendering!", "SDeferredShadowManager::PrepareShadowTexture", true);
374 // Set auto_param ACT_TEXTURE_VIEWPROJ_MATRIX, it's not bounded correctly when we do not use Ogre's internal shadows.
395void SDeferredShadowManager::PrepareShadowTextureImpl(Ogre::SceneManager* ogreTargetScene, Ogre::Camera* ogreCamera, Ogre::Viewport* ogreViewport, const Ogre::Light* ogreLight)
402 StandardTextureCameraByScene::iterator iCamera = standardTextureCameraByScene.find(ogreTargetScene);
429 spotShadowCameraSetup->getShadowCamera(ogreTargetScene, ogreCamera, ogreViewport, ogreLight, ogreShadowCamera, 0);
433 directionalShadowCameraSetup->getShadowCamera(ogreTargetScene, ogreCamera, ogreViewport, ogreLight, ogreShadowCamera, 0);
437 shadowStandardMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setProjectiveTexturing(true, ogreShadowCamera);
446void SDeferredShadowManager::PrepareShadowCubicTextureImpl(Ogre::SceneManager* ogreTargetScene, Ogre::Camera* ogreCamera, Ogre::Viewport* ogreViewport, const Ogre::Light* ogreLight)
453 std::vector<Ogre::Camera*> ogreCubicCameras = cubicTextureCamerasByScene.find(ogreTargetScene)->second;
480 pointShadowCameraSetup->getShadowCamera(ogreTargetScene, ogreCamera, ogreViewport, ogreLight, ogreShadowCamera, 0);
515 shadowCubicMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setProjectiveTexturing(true, ogreShadowCamera);
525Ogre::Technique* SDeferredShadowManager::handleSchemeNotFound(unsigned short schemeIndex, const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex, const Ogre::Renderable* rend)
544 Ogre::MaterialPtr shadowCasterMaterial = Ogre::MaterialManager::getSingleton().getByName(SO3_DEFERRED_SHADOW_CASTER_NAME);
546 SO3_EXCEPT(SExceptionItemNotFound, "Cannot locate the shadow caster material named \"" + std::string(SO3_DEFERRED_SHADOW_CASTER_NAME) + "'", "SDeferredShadowManager::handleSchemeNotFound", true);
576 shadowPass->setAlphaRejectSettings(originalPass->getAlphaRejectFunction(), originalPass->getAlphaRejectValue());
577 shadowPass->setSceneBlending(originalPass->getSourceBlendFactor(), originalPass->getDestBlendFactor());
589 // override colour function. I use additive shadows, so set it to black. With non-additive shadow technique it should be the shadow colour.
590 shadowTextureUnit->setColourOperationEx(Ogre::LBX_SOURCE1, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, Ogre::ColourValue::Black);
void RegisterSceneManager(Ogre::SceneManager *targetScene)
Definition SO3DeferredShadowManager.cpp:104
static SDeferredShadowManager * getSingletonPtr()
Definition SO3DeferredShadowManager.cpp:93
void SetShadowStandardTextureFSAA(unsigned short fsaa)
Definition SO3DeferredShadowManager.cpp:198
SDeferredShadowManager()
Definition SO3DeferredShadowManager.cpp:34
void SetShadowStandardTextureSize(unsigned short size)
Definition SO3DeferredShadowManager.cpp:182
void SetShadowCubicTextureSize(unsigned short size)
Definition SO3DeferredShadowManager.cpp:206
static SDeferredShadowManager & getSingleton()
Definition SO3DeferredShadowManager.cpp:98
void UnregisterSceneManager(Ogre::SceneManager *existingScene)
Definition SO3DeferredShadowManager.cpp:135
void SetShadowStandardTexturePixelFormat(Ogre::PixelFormat fmt)
Definition SO3DeferredShadowManager.cpp:190
Ogre::TexturePtr & PrepareShadowTexture(Ogre::Camera *ogreCamera, Ogre::Viewport *ogreViewport, const Ogre::Light *light, Ogre::Pass *ogrePass)
Definition SO3DeferredShadowManager.cpp:353
void SetShadowTextureFSAA(unsigned short fsaa)
Definition SO3DeferredShadowManager.cpp:176
void SetShadowTextureSize(unsigned short size)
Definition SO3DeferredShadowManager.cpp:164
void SetShadowTexturePixelFormat(Ogre::PixelFormat fmt)
Definition SO3DeferredShadowManager.cpp:170
void SetShadowCubicTexturePixelFormat(Ogre::PixelFormat fmt)
Definition SO3DeferredShadowManager.cpp:214
~SDeferredShadowManager()
Definition SO3DeferredShadowManager.cpp:81
void SetShadowCubicTextureFSAA(unsigned short fsaa)
Definition SO3DeferredShadowManager.cpp:222
virtual Ogre::Technique * handleSchemeNotFound(unsigned short schemeIndex, const Ogre::String &schemeName, Ogre::Material *originalMaterial, unsigned short lodIndex, const Ogre::Renderable *rend)
Definition SO3DeferredShadowManager.cpp:525
SException indicating that an attempt to create a new item with a given identifier fails cause anothe...
Definition SO3Exception.h:165
SException indicating that an attempt to get an item fails, cause there's no item with the given iden...
Definition SO3Exception.h:180
Definition SO3DataScol.h:38
Generated by 1.9.8