//----------------------------------------------------------------------- void CompositorChain::setCompositorEnabled(size_t position, bool state) { CompositorInstance* inst = getCompositor(position); if (!state && inst->getEnabled()) { // If we're disabling a 'middle' compositor in a chain, we have to be // careful about textures which might have been shared by non-adjacent // instances which have now become adjacent. CompositorInstance* nextInstance = getNextInstance(inst, true); if (nextInstance) { CompositionTechnique::TargetPassIterator tpit = nextInstance->getTechnique()->getTargetPassIterator(); while(tpit.hasMoreElements()) { CompositionTargetPass* tp = tpit.getNext(); if (tp->getInputMode() == CompositionTargetPass::IM_PREVIOUS) { if (nextInstance->getTechnique()->getTextureDefinition(tp->getOutputName())->pooled) { // recreate nextInstance->freeResources(false, true); nextInstance->createResources(false); } } } } } inst->setEnabled(state); }
//--------------------------------------------------------------------- void CompositorManager::_reconstructAllCompositorResources() { // In order to deal with shared resources, we have to disable *all* compositors // first, that way shared resources will get freed typedef vector<CompositorInstance*>::type InstVec; InstVec instancesToReenable; for (Chains::iterator i = mChains.begin(); i != mChains.end(); ++i) { CompositorChain* chain = i->second; CompositorChain::InstanceIterator instIt = chain->getCompositors(); while (instIt.hasMoreElements()) { CompositorInstance* inst = instIt.getNext(); if (inst->getEnabled()) { inst->setEnabled(false); instancesToReenable.push_back(inst); } } } //UVs are lost, and will never be reconstructed unless we do them again, now if( mRectangle ) mRectangle->setDefaultUVs(); for (InstVec::iterator i = instancesToReenable.begin(); i != instancesToReenable.end(); ++i) { CompositorInstance* inst = *i; inst->setEnabled(true); } }
void DeferredShadingSystem::logCurrentMode(void) { if(mActive == false) { LogManager::getSingleton().logMessage("No Compositor Enabled!"); return; } CompositorInstance* ci = mInstance[mCurrentMode]; assert(ci->getEnabled() == true); LogManager::getSingleton().logMessage("Current Mode: "); LogManager::getSingleton().logMessage(ci->getCompositor()->getName()); }
//--------------------------------------------------------------------- void CompositorManager::_reconstructAllCompositorResources() { for (Chains::iterator i = mChains.begin(); i != mChains.end(); ++i) { CompositorChain* chain = i->second; CompositorChain::InstanceIterator instIt = chain->getCompositors(); while (instIt.hasMoreElements()) { CompositorInstance* inst = instIt.getNext(); if (inst->getEnabled()) { inst->setEnabled(false); inst->setEnabled(true); } } } }
//----------------------------------------------------------------------------------- void Sample_Compositor::changePage(size_t pageNum) { assert(pageNum < mNumCompositorPages); mActiveCompositorPage = pageNum; size_t maxCompositorsInPage = mCompositorNames.size() - (pageNum * COMPOSITORS_PER_PAGE); for (size_t i=0; i < COMPOSITORS_PER_PAGE; i++) { String checkBoxName = "Compositor_" + Ogre::StringConverter::toString(i); CheckBox* cb = static_cast<CheckBox*>(mTrayMgr->getWidget(TL_TOPLEFT, checkBoxName)); if (i < maxCompositorsInPage) { String compositorName = mCompositorNames[pageNum * COMPOSITORS_PER_PAGE + i]; CompositorInstance *tmpCompo = CompositorManager::getSingleton().getCompositorChain(mViewport) ->getCompositor(compositorName); cb->setCaption(compositorName); if( tmpCompo ) { cb->setChecked( tmpCompo->getEnabled(), false ); cb->show(); } else { cb->setChecked( false, false ); cb->hide(); } } else { cb->hide(); } } OgreBites::Button* pageButton = static_cast<OgreBites::Button*>(mTrayMgr->getWidget(TL_TOPLEFT, "PageButton")); Ogre::StringStream ss; ss << "Compositors " << pageNum + 1 << "/" << mNumCompositorPages; pageButton->setCaption(ss.str()); }
void DeferredShadingSystem::logCurrentMode(void) { if (mActive==false) { LogManager::getSingleton().logMessage("No Compositor Enabled!"); return; } CompositorInstance* ci = mInstance[mCurrentMode]; assert(ci->getEnabled()==true); LogManager::getSingleton().logMessage("Current Mode: "); LogManager::getSingleton().logMessage(ci->getCompositor()->getName()); if (mCurrentMode==DSM_SHOWLIT) { LogManager::getSingleton().logMessage("Current mrt outputs are:"); LogManager::getSingleton().logMessage(ci->getTextureInstanceName("mrt_output", 0)); LogManager::getSingleton().logMessage(ci->getTextureInstanceName("mrt_output", 1)); } }
//--------------------------------------------------------------------- void CompositorInstance::deriveTextureRenderTargetOptions( const String& texname, bool *hwGammaWrite, uint *fsaa) { // search for passes on this texture def that either include a render_scene // or use input previous bool renderingScene = false; CompositionTechnique::TargetPassIterator it = mTechnique->getTargetPassIterator(); while (it.hasMoreElements()) { CompositionTargetPass* tp = it.getNext(); if (tp->getOutputName() == texname) { if (tp->getInputMode() == CompositionTargetPass::IM_PREVIOUS) { // this may be rendering the scene implicitly // Can't check mPreviousInstance against mChain->_getOriginalSceneCompositor() // at this time, so check the position CompositorChain::InstanceIterator instit = mChain->getCompositors(); renderingScene = true; while(instit.hasMoreElements()) { CompositorInstance* inst = instit.getNext(); if (inst == this) break; else if (inst->getEnabled()) { // nope, we have another compositor before us, this will // be doing the AA renderingScene = false; } } if (renderingScene) break; } else { // look for a render_scene pass CompositionTargetPass::PassIterator pit = tp->getPassIterator(); while(pit.hasMoreElements()) { CompositionPass* pass = pit.getNext(); if (pass->getType() == CompositionPass::PT_RENDERSCENE) { renderingScene = true; break; } } } } } if (renderingScene) { // Ok, inherit settings from target RenderTarget* target = mChain->getViewport()->getTarget(); *hwGammaWrite = target->isHardwareGammaEnabled(); *fsaa = target->getFSAA(); } else { *hwGammaWrite = false; *fsaa = 0; } }