Today I ran into the same problem and I was glad to find your post.
However, for me this solution was not suitable because (in contrast to you) I wanted the glow effect to apply also to the ribbon-trails (as well as to particle-effects and other billboards). Also I did not like the idea of tampering with render queues, at least not at this stage of my project.
I found a different solution which is not optimal either, but it works pretty well for my setup.
It's important to understand how the glow effect works. It uses a specific material scheme called "glow" to draw a glow-map of the scene (which is then blurred and added to the original scene). For every material, there are two possibilities:
a) It contains a technique for the material scheme "glow" -> the technique is used to draw the material to the glow map
b) It does not contain a suitable technique -> the material is painted with an opaque black to the glow map (the black material is defined in GlowMaterialListener.h)
The problem is: The ribbon-trail doesn't define a "glow" technique, thus it is rendered as an opaque black material to the glow-map which means that the glowing background is hidden behind the ribbon-trail.
In other words: Even though the ribbon-trail's material is transparent in the real scene, the fallback-material that is used for the glow map is NOT transparent.
There are two possible solutions:
1) Define a "glow" technique for the ribbon-trail's material (and every other transparent material). The glow-technique must be transparent itself as well, otherwise it will still block the glow effect.
2) Enhance GlowMaterialListener.h to use a transparent fallback-material if the original material is transparent.
For the moment I went with solution (2) because I did not want to modify all transparent materials in my project. Maybe I'll change that in the future because I feel like solution (1) offers more control over the rendered scene.
Anyway, here's how GlowMaterialListener looks for solution 2:
Code: Select all
class GlowMaterialListener : public Ogre::MaterialManager::Listener
{
public:
GlowMaterialListener()
{
mBlackMat = Ogre::MaterialManager::getSingleton().create("mGlowBlack", "Internal");
mBlackMat->getTechnique(0)->getPass(0)->setDiffuse(0,0,0,0);
mBlackMat->getTechnique(0)->getPass(0)->setSpecular(0,0,0,0);
mBlackMat->getTechnique(0)->getPass(0)->setAmbient(0,0,0);
mBlackMat->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,0);
mTransparentMat = Ogre::MaterialManager::getSingleton().create("mGlowTransparent", "Internal");
mTransparentMat->getTechnique(0)->getPass(0)->setDiffuse(0,0,0,0);
mTransparentMat->getTechnique(0)->getPass(0)->setSpecular(0,0,0,0);
mTransparentMat->getTechnique(0)->getPass(0)->setAmbient(0,0,0);
mTransparentMat->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,0);
mTransparentMat->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_ADD);
mTransparentMat->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
}
Ogre::Technique* handleSchemeNotFound(unsigned short, const Ogre::String& schemeName, Ogre::Material* mat, unsigned short, const Ogre::Renderable*)
{
if (schemeName == "glow")
{
// try to figure out if the original material is transparent. if yes, use a black transparent material, otherwise a black opaque one.
if (mat->isTransparent())
return mTransparentMat->getTechnique(0);
else
return mBlackMat->getTechnique(0);
}
return NULL;
}
private:
Ogre::MaterialPtr mBlackMat;
Ogre::MaterialPtr mTransparentMat;
};
I hope this helps someone.