81 SAFE_DELETE(deferredShadowManager);
84 if(gBufferSchemeHandler)
86 Ogre::MaterialManager::getSingleton().removeListener(gBufferSchemeHandler);
87 SO3_SAFE_DELETE(gBufferSchemeHandler);
91 if(noGBufferSchemeHandler)
93 Ogre::MaterialManager::getSingleton().removeListener(noGBufferSchemeHandler);
94 SO3_SAFE_DELETE(noGBufferSchemeHandler);
98 Ogre::CompositorManager& compMan = Ogre::CompositorManager::getSingleton();
99 if(ssaoCompositorLogic)
101 compMan.unregisterCompositorLogic(
"SSAOLogic");
102 SO3_SAFE_DELETE(ssaoCompositorLogic);
114 SO3_SAFE_DELETE(compositorGBuffer);
115 SO3_SAFE_DELETE(compositorLighting);
116 SO3_SAFE_DELETE(compositorShowDepth);
117 SO3_SAFE_DELETE(compositorShowDiffuse);
118 SO3_SAFE_DELETE(compositorShowEmissive);
119 SO3_SAFE_DELETE(compositorShowMaterialID);
120 SO3_SAFE_DELETE(compositorShowNormal);
121 SO3_SAFE_DELETE(compositorShowSpecular);
122 SO3_SAFE_DELETE(compositorShowVelocity);
123 SO3_SAFE_DELETE(compositorSSAO);
124 SO3_SAFE_DELETE(compositorSSAA);
125 SO3_SAFE_DELETE(compositorNFAA);
126 SO3_SAFE_DELETE(deferredLightManager);
127 SO3_SAFE_DELETE(gbufferMaterialGenerator);
130 AvailableGBufferMap::iterator iGBuffer = availableGBufferMap.begin();
131 while(iGBuffer != availableGBufferMap.end())
133 SO3_SAFE_DELETE(iGBuffer->second);
136 availableGBufferMap.clear();
152 OgreViewportList::iterator ogreViewportSearched =
ogreViewportList.find(targetViewport);
154 SO3_EXCEPT(
SExceptionItemIdentity,
"Trying to register an already registered viewport!",
"SDeferredShading::RegisterViewport",
true);
157 Ogre::CompositorManager& compMan = Ogre::CompositorManager::getSingleton();
158 static bool firstTime =
true;
162 Ogre::RenderSystem* ogreRenderSystem = Ogre::Root::getSingleton().getRenderSystem();
163 const Ogre::RenderSystemCapabilities* ogreCapabilities = ogreRenderSystem ->getCapabilities();
166 if (!ogreCapabilities->hasCapability(Ogre::RSC_VERTEX_PROGRAM) || !(ogreCapabilities->hasCapability(Ogre::RSC_FRAGMENT_PROGRAM)))
167 SO3_EXCEPT(
SExceptionUnimplemented,
"Your card does not support vertex and fragment programs!",
"SDeferredShading::SDeferredShading",
true);
170 if (ogreCapabilities->getNumMultiRenderTargets()<2)
171 SO3_EXCEPT(
SExceptionUnimplemented,
"Your card does not support at least two simultaneous render targets!",
"SDeferredShading::SDeferredShading",
true);
175 availableGBufferMap.insert(AvailableGBufferMap::value_type(currentGBuffer->
GetName(), currentGBuffer));
178 if (ogreCapabilities->getNumMultiRenderTargets()<4)
180 Ogre::LogManager::getSingleton().logMessage(
"Your card does not support at least four simultaneous render targets, high resolution deferred will not be available!");
186 availableGBufferMap.insert(AvailableGBufferMap::value_type(currentGBuffer->
GetName(), currentGBuffer));
192 Ogre::MaterialManager::getSingleton().addListener(gBufferSchemeHandler,
"GBuffer");
193 Ogre::MaterialManager::getSingleton().addListener(noGBufferSchemeHandler,
"NoGBuffer");
197 compMan.registerCompositorLogic(
"SSAOLogic", ssaoCompositorLogic);
199 compMan.registerCustomCompositionPass(
"DeferredLight", deferredLightCompositionPass);
209 viewportGBufferFilters->
gBufferInstance = compMan.addCompositor(ogreTargetViewport, compositorGBuffer->
GetCompositor(currentGBuffer)->getName(), 0);
223 viewportGBufferFilters->
ssaoCompositor = compMan.addCompositor(ogreTargetViewport, compositorSSAO->
GetCompositor(currentGBuffer)->getName(), 2);
230 ogreViewportList.insert(OgreViewportList::value_type(targetViewport, viewportGBufferFilters));
236 newViewportAdded =
true;
243 OgreViewportList::iterator ogreViewportSearched =
ogreViewportList.find(existingViewport);
249 Ogre::CompositorChain* chain = Ogre::CompositorManager::getSingleton().getCompositorChain(ogreTargetViewport);
252 chain->_removeInstance(ogreViewportSearched->second->gBufferCompositors[i]);
255 chain->_removeInstance(ogreViewportSearched->second->antiAliasingCompositors[i]);
257 chain->_removeInstance(ogreViewportSearched->second->ssaoCompositor);
258 chain->_removeInstance(ogreViewportSearched->second->gBufferInstance);
262 if(chain->getNumCompositors() == 0)
263 Ogre::CompositorManager::getSingleton().removeCompositorChain(ogreTargetViewport);
267 SO3_SAFE_DELETE(ogreViewportSearched->second);