Hello,
I'm trying to use OgreBites::SGTechniqueResolverListener to create alternative rendering for the materials in my scene.
I defined a couple of schemes and for each of them I have a class inheriting SGTechniqueResolverListener in which i have specific implementations of handleSchemeNotFound. These listeners are registered into the MaterialManager. I then have different viewports connected to the same camera viewing the scene. Each viewport refers to a scheme.
It works rather well if variations of the technique consists in changing the ambiant, the diffuse, the specular or the emissive colors.
But trying to modify the texture units does not work.
Example (which is working):
The viewport in the upper right corner shows the scene with per material instance color.
It corresponds to the following SGTechniqueResolverListener derivation:
Code: Select all
TechniqueResolverListener::TechniqueResolverListener(Ogre::RTShader::ShaderGenerator* shaderGenerator)
: OgreBites::SGTechniqueResolverListener{shaderGenerator}, m_key{0u}
{
}
Ogre::Technique* TechniqueResolverListener::handleSchemeNotFound(
unsigned short schemeIndex,
const Ogre::String& schemeName,
Ogre::Material* originalMaterial,
unsigned short lodIndex,
const Ogre::Renderable* rend)
{
const auto color = getColor(fmt::format("{}/{}", originalMaterial->getGroup(), originalMaterial->getName()));
Ogre::Technique* pTech = OgreBites::SGTechniqueResolverListener::handleSchemeNotFound(
schemeIndex, schemeName, originalMaterial, lodIndex, rend);
if (pTech != nullptr) {
for (auto* pass : pTech->getPasses()) {
pass->setLightingEnabled(false);
pass->setDiffuse(Ogre::ColourValue::Black);
pass->setSpecular(Ogre::ColourValue::Black);
pass->setAmbient(Ogre::ColourValue::Black);
pass->setSelfIllumination(color);
pass->setColourWriteEnabled(true);
}
}
return pTech;
}
What i fail to achieve:
I want to change the texture-units of the passes (actually only one) to only keep the transparency and force the color (from the texture) to be white
So I changed my code to:
Code: Select all
Ogre::Technique* TechniqueResolverListener::handleSchemeNotFound(
unsigned short schemeIndex,
const Ogre::String& schemeName,
Ogre::Material* originalMaterial,
unsigned short lodIndex,
const Ogre::Renderable* rend)
{
const auto color = getColor(fmt::format("{}/{}", originalMaterial->getGroup(), originalMaterial->getName()));
Ogre::Technique* pTech = OgreBites::SGTechniqueResolverListener::handleSchemeNotFound(
schemeIndex, schemeName, originalMaterial, lodIndex, rend);
if (pTech != nullptr) {
for (auto* pass : pTech->getPasses()) {
//-----
for (auto* tex_unit : pass->getTextureUnitStates()) {
tex_unit->setColourOperationEx(
Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, Ogre::ColourValue::White);
tex_unit->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_TEXTURE, Ogre::LBS_CURRENT);
}
//-----
pass->setLightingEnabled(false);
pass->setDiffuse(Ogre::ColourValue::Black);
pass->setSpecular(Ogre::ColourValue::Black);
pass->setAmbient(Ogre::ColourValue::Black);
pass->setSelfIllumination(color);
pass->setColourWriteEnabled(true);
}
}
return pTech;
}
but textures are not impacted : i don't get the 'flat color aspect' i expect.
Any idea?
BTW, my context is: Ogre 14.2.6 Feodra40, GL3+