When I try to make changes to the 2nd pass dynamically they don't take affect other than the 1st time.
A simple
Code: Select all
ppass->setDiffuse(1.0f, 1.0f, 1.0f, opacity);
Here is my code:
Code: Select all
Ogre::MaterialPtr Mat = m_mmgr->getByName(m_MaterialName);
Ogre::Pass* ppass;
Ogre::TextureUnitState* ptus;
//Background
if (Mat->getTechnique(0)->getNumPasses() < 1)
ppass = Mat->getTechnique(0)->createPass();
else
ppass = Mat->getTechnique(0)->getPass(0);
if (ppass->getNumTextureUnitStates() < 1)
ptus = ppass->createTextureUnitState();
else
ptus = ppass->getTextureUnitState(0);
//First Time
if (ptus->getTextureName() != m_BGTexture->getName())
{
ppass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
ptus->setTexture(m_BGTexture);
ptus->setTextureAddressingMode(Ogre::TextureUnitState::TextureAddressingMode::TAM_CLAMP);
ptus->setTextureFiltering(Ogre::TextureFilterOptions::TFO_ANISOTROPIC);
}
ppass->setDiffuse(1.0f, 1.0f, 1.0f, opacity);
//Create Text
if (Mat->getTechnique(0)->getNumPasses() < 2)
ppass = Mat->getTechnique(0)->createPass();
else
ppass = Mat->getTechnique(0)->getPass(1);
//First Time
if (ppass->getNumTextureUnitStates() < 1)
{
ppass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
ptus = ppass->createTextureUnitState();
ptus->setColourOperationEx(LBX_BLEND_TEXTURE_ALPHA);
ptus->setTextureAddressingMode(Ogre::TextureUnitState::TextureAddressingMode::TAM_CLAMP);
ptus->setTextureFiltering(Ogre::TextureFilterOptions::TFO_ANISOTROPIC);
ptus->setTexture(m_Texture);
}
else
ptus = ppass->getTextureUnitState(0);
ppass->setDiffuse(1.0f, 1.0f, 1.0f, opacity);