bool MainCamera::validateCompositionTargetPass(Ogre::CompositionTargetPass& compositionPass)
{
	Ogre::CompositionTargetPass::PassIterator compPassIter = compositionPass.getPassIterator();
	while (compPassIter.hasMoreElements()) {
		Ogre::CompositionPass* compositorPass = compPassIter.getNext();
		compositorPass->getMaterial()->load();
		Ogre::Material::TechniqueIterator techIter = compositorPass->getMaterial()->getSupportedTechniqueIterator();
		while (techIter.hasMoreElements()) {
			Ogre::Technique::PassIterator _passIter = techIter.getNext()->getPassIterator();
			while (_passIter.hasMoreElements()) {
				Ogre::Pass* pass = _passIter.getNext();
				//Also disallow camera polygon mode overide. This is because if it's turned on,
				//and the camera is switched to polygon mode, the end result will be one single
				//large polygon being shown. This is not what we want.
				pass->setPolygonModeOverrideable(false);
				if (pass->hasFragmentProgram()) {
					if (pass->getFragmentProgram()->hasCompileError()) {
						return false;
					}
				}
			}
		}
	}
	return true;
}
Exemplo n.º 2
0
 void CompositionHandler::SetCompositorTargetParameters(Ogre::CompositionTargetPass *target, const QList< std::pair<std::string, Ogre::Vector4> > &source) const
 {
     if (target)
         for(uint p=0 ; p<target->getNumPasses() ; ++p)
         {
             Ogre::CompositionPass *pass = target->getPass(p);
             if (pass)
                 SetMaterialParameters(pass->getMaterial(), source);
         }
 }
Exemplo n.º 3
0
KBOOL Kylin::EffectFade::Initialize()
{

    Ogre::CompositorPtr spCompositor = Ogre::CompositorManager::getSingleton().create(
                                           m_sName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
                                       );

    Ogre::CompositionTechnique *t;
    Ogre::CompositionTechnique::TextureDefinition *td;
    Ogre::CompositionTargetPass *tp;
    Ogre::CompositionPass *pass;

    t = spCompositor->createTechnique();
    td = t->createTextureDefinition("scene");
    td->width = 1;
    td->height = 1;
    td->formatList.push_back(Ogre::PF_X8R8G8B8);

    tp = t->createTargetPass();
    tp->setInputMode(Ogre::CompositionTargetPass::IM_PREVIOUS);
    tp->setOutputName("scene");

    tp = t->getOutputTargetPass();
    tp->setInputMode(Ogre::CompositionTargetPass::IM_NONE);
    pass = tp->createPass();
    pass->setType(Ogre::CompositionPass::PT_RENDERQUAD);
    pass->setMaterialName("PostFilters/Fade");
    pass->setInput(0, "scene");
    pass->setIdentifier(0xDEADBADE);

    // receive default parameters from material script
    m_fColourAmount = 0;
    m_fGrayAmount	= 1;
    if (!pass->getMaterial().isNull())
    {
        Ogre::GpuProgramParametersSharedPtr parameters = pass->getMaterial()->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
        /*#if OGRE_VERSION >= 0x010300*/
        const Ogre::GpuConstantDefinition* def;

        def = parameters->_findNamedConstantDefinition("colour_amount");
        if (def)
            parameters->_readRawConstants(def->physicalIndex, 1, &m_fColourAmount);
        def = parameters->_findNamedConstantDefinition("gray_amount");
        if (def)
            parameters->_readRawConstants(def->physicalIndex, 1, &m_fGrayAmount);
// #else
// 		GpuProgramParameters::RealConstantEntry* entry;
//
// 		entry = parameters->getNamedRealConstantEntry("colour_amount");
// 		if (entry && entry->isSet)
// 			m_fColourAmount = entry->val[0];
//
// 		entry = parameters->getNamedRealConstantEntry("gray_amount");
// 		if (entry && entry->isSet)
// 			m_fGrayAmount = entry->val[0];
// #endif
    }

    KBOOL bRet = EffectCompositor::Initialize();

    if (bRet)
        m_pCompositor->addListener(this);

    return bRet;
}