Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11089 for code/trunk


Ignore:
Timestamp:
Jan 24, 2016, 2:25:45 PM (9 years ago)
Author:
landauf
Message:

glow effect is now visible through transparent elements (e.g. billboards, particle effects, etc.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/core/GlowMaterialListener.h

    r11085 r11089  
    1717                mBlackMat->getTechnique(0)->getPass(0)->setAmbient(0,0,0);
    1818                mBlackMat->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,0);
     19
     20                mTransparentMat = Ogre::MaterialManager::getSingleton().create("mGlowTransparent", "Internal");
     21                mTransparentMat->getTechnique(0)->getPass(0)->setDiffuse(0,0,0,0);
     22                mTransparentMat->getTechnique(0)->getPass(0)->setSpecular(0,0,0,0);
     23                mTransparentMat->getTechnique(0)->getPass(0)->setAmbient(0,0,0);
     24                mTransparentMat->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,0);
     25                mTransparentMat->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_ADD);
     26                mTransparentMat->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
    1927            }
    2028
    21             Ogre::Technique* handleSchemeNotFound(unsigned short, const Ogre::String& schemeName, Ogre::Material*mat, unsigned short, const Ogre::Renderable*)
     29            Ogre::Technique* handleSchemeNotFound(unsigned short, const Ogre::String& schemeName, Ogre::Material* mat, unsigned short, const Ogre::Renderable*)
    2230            {
    2331                if (schemeName == "glow")
    2432                {
    25                     //LogManager::getSingleton().logMessage(">> adding glow to material: "+mat->getName());
    26                     return mBlackMat->getTechnique(0);
     33                    // try to figure out if the original material is transparent. if yes, use a black transparent material, otherwise a black opaque one.
     34                    if (mat != nullptr && mat->getTechnique(0) != nullptr && mat->getTechnique(0)->getPass(0) != nullptr)
     35                    {
     36                        Ogre::Pass* pass = mat->getTechnique(0)->getPass(0);
     37                        if (pass->getDepthWriteEnabled())
     38                            return mBlackMat->getTechnique(0);
     39                        else
     40                            return mTransparentMat->getTechnique(0);
     41                    }
     42                    else
     43                        return mBlackMat->getTechnique(0);
    2744                }
    2845                return NULL;
     
    3148        private:
    3249            Ogre::MaterialPtr mBlackMat;
     50            Ogre::MaterialPtr mTransparentMat;
    3351    };
    3452}
Note: See TracChangeset for help on using the changeset viewer.