Exemplo n.º 1
0
Ogre::Technique* GBufferSchemeHandler::handleSchemeNotFound(unsigned short schemeIndex, 
		const Ogre::String& schemeName, Ogre::Material* originalMaterial, unsigned short lodIndex, 
		const Ogre::Renderable* rend)
{
	Ogre::MaterialManager& matMgr = Ogre::MaterialManager::getSingleton();
	Ogre::String curSchemeName = matMgr.getActiveScheme();
	matMgr.setActiveScheme(Ogre::MaterialManager::DEFAULT_SCHEME_NAME);
	Ogre::Technique* originalTechnique = originalMaterial->getBestTechnique(lodIndex, rend);
	matMgr.setActiveScheme(curSchemeName);

	Ogre::Technique* gBufferTech = originalMaterial->createTechnique();
	gBufferTech->removeAllPasses();
	gBufferTech->setSchemeName(schemeName);

	Ogre::Technique* noGBufferTech = originalMaterial->createTechnique();
	noGBufferTech->removeAllPasses();
	noGBufferTech->setSchemeName("NoGBuffer");

	for (unsigned short i=0; i<originalTechnique->getNumPasses(); i++)
	{
		Ogre::Pass* originalPass = originalTechnique->getPass(i);
		PassProperties props = inspectPass(originalPass, lodIndex, rend);
		
		if (!props.isDeferred)
		{
			//Just copy the technique so it gets rendered regularly
			Ogre::Pass* clonePass = noGBufferTech->createPass();
			*clonePass = *originalPass;
			continue;
		}

		Ogre::Pass* newPass = gBufferTech->createPass();
		MaterialGenerator::Perm perm = getPermutation(props);

		const Ogre::MaterialPtr& templateMat = mMaterialGenerator.getMaterial(perm);
    	
		//We assume that the GBuffer technique contains only one pass. But its true.
		*newPass = *(templateMat->getTechnique(0)->getPass(0));
		fillPass(newPass, originalPass, props);    
	}
    
	return gBufferTech;
}
Exemplo n.º 2
0
	bool OgreMaterial::createConfiguration (const std::string& name)
	{
		for (int i=0; i<mMaterial->getNumTechniques(); ++i)
		{
			if (mMaterial->getTechnique(i) == mMaterial->getTechnique(name))
				return false;
		}

		Ogre::Technique* t = mMaterial->createTechnique();
		t->setSchemeName (name);
		t->setName (name);
		if (mShadowCasterMaterial != "")
			t->setShadowCasterMaterial(mShadowCasterMaterial);

		return true;
	}
Exemplo n.º 3
0
	bool OgreMaterial::createConfiguration (const std::string& name, unsigned short lodIndex)
	{
		for (int i=0; i<mMaterial->getNumTechniques(); ++i)
		{
			if (mMaterial->getTechnique(i)->getSchemeName() == name && mMaterial->getTechnique(i)->getLodIndex() == lodIndex)
				return false;
		}

		Ogre::Technique* t = mMaterial->createTechnique();
		t->setSchemeName (name);
		t->setLodIndex (lodIndex);
		if (mShadowCasterMaterial != "")
			t->setShadowCasterMaterial(mShadowCasterMaterial);

		mMaterial->compile();

		return true;
	}