void gkOgreCompositorHDRListener::notifyCompositor(Ogre::CompositorInstance* instance) { // Get some RTT dimensions for later calculations Ogre::CompositionTechnique::TextureDefinitionIterator defIter = instance->getTechnique()->getTextureDefinitionIterator(); while (defIter.hasMoreElements()) { Ogre::CompositionTechnique::TextureDefinition* def = defIter.getNext(); if(def->name == "rt_bloom0") { mBloomSize = (int)def->width; // should be square // Calculate gaussian texture offsets & weights float deviation = 3.0f; float texelSize = 1.0f / (float)mBloomSize; // central sample, no offset mBloomTexOffsetsHorz[0][0] = 0.0f; mBloomTexOffsetsHorz[0][1] = 0.0f; mBloomTexOffsetsVert[0][0] = 0.0f; mBloomTexOffsetsVert[0][1] = 0.0f; mBloomTexWeights[0][0] = mBloomTexWeights[0][1] = mBloomTexWeights[0][2] = Ogre::Math::gaussianDistribution(0, 0, deviation); mBloomTexWeights[0][3] = 1.0f; // 'pre' samples for(int i = 1; i < 8; ++i) { mBloomTexWeights[i][0] = mBloomTexWeights[i][1] = mBloomTexWeights[i][2] = 1.25f * Ogre::Math::gaussianDistribution((Ogre::Real)i, 0, deviation); mBloomTexWeights[i][3] = 1.0f; mBloomTexOffsetsHorz[i][0] = i * texelSize; mBloomTexOffsetsHorz[i][1] = 0.0f; mBloomTexOffsetsVert[i][0] = 0.0f; mBloomTexOffsetsVert[i][1] = i * texelSize; } // 'post' samples for(int i = 8; i < 15; ++i) { mBloomTexWeights[i][0] = mBloomTexWeights[i][1] = mBloomTexWeights[i][2] = mBloomTexWeights[i - 7][0]; mBloomTexWeights[i][3] = 1.0f; mBloomTexOffsetsHorz[i][0] = -mBloomTexOffsetsHorz[i - 7][0]; mBloomTexOffsetsHorz[i][1] = 0.0f; mBloomTexOffsetsVert[i][0] = 0.0f; mBloomTexOffsetsVert[i][1] = -mBloomTexOffsetsVert[i - 7][1]; } } } }
//--------------------------------------------------------------------- void CompositorDemo_FrameListener::updateDebugRTTWindow(void) { // Clear listbox mDebugRTTListbox->resetList(); // Clear imagesets mDebugRTTStaticImage->setProperty("Image", ""); for (ImageSetList::iterator isIt = mDebugRTTImageSets.begin(); isIt != mDebugRTTImageSets.end(); ++isIt) { CEGUI::ImagesetManager::getSingleton().destroyImageset(*isIt); } mDebugRTTImageSets.clear(); Ogre::set<Ogre::String>::type uniqueTextureNames; // Add an entry for each render texture for all active compositors Ogre::Viewport* vp = mMain->getRenderWindow()->getViewport(0); Ogre::CompositorChain* chain = Ogre::CompositorManager::getSingleton().getCompositorChain(vp); Ogre::CompositorChain::InstanceIterator it = chain->getCompositors(); while (it.hasMoreElements()) { Ogre::CompositorInstance* inst = it.getNext(); if (inst->getEnabled()) { Ogre::CompositionTechnique::TextureDefinitionIterator texIt = inst->getTechnique()->getTextureDefinitionIterator(); while (texIt.hasMoreElements()) { Ogre::CompositionTechnique::TextureDefinition* texDef = texIt.getNext(); // Get instance name of texture (NB only index 0 if MRTs for now) const Ogre::String& instName = inst->getTextureInstanceName(texDef->name, 0); // Create CEGUI texture from name of OGRE texture CEGUI::Texture* tex = mMain->getGuiRenderer()->createTexture(instName.c_str()); // Create imageset // Note that if we use shared textures in compositor, the same texture name // will occur more than once, so we have to cater for this if (uniqueTextureNames.find(instName) == uniqueTextureNames.end()) { CEGUI::Imageset* imgSet = CEGUI::ImagesetManager::getSingleton().createImageset( instName.c_str(), tex); mDebugRTTImageSets.push_back(imgSet); imgSet->defineImage((CEGUI::utf8*)"RttImage", CEGUI::Point(0.0f, 0.0f), CEGUI::Size(tex->getWidth(), tex->getHeight()), CEGUI::Point(0.0f,0.0f)); CEGUI::ListboxTextItem *item = new CEGUI::ListboxTextItem(texDef->name.c_str(), 0, imgSet); item->setSelectionBrushImage("TaharezLook", "ListboxSelectionBrush"); item->setSelectionColours(CEGUI::colour(0,0,1)); mDebugRTTListbox->addItem(item); uniqueTextureNames.insert(instName); } } } } }