Index: code/branches/shaders/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/shaders/src/orxonox/CMakeLists.txt	(revision 9403)
+++ code/branches/shaders/src/orxonox/CMakeLists.txt	(revision 9407)
@@ -37,4 +37,5 @@
   CameraManager.cc
   Scene.cc
+  RenderQueueListener.cc
 END_BUILD_UNIT
 )
Index: code/branches/shaders/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/shaders/src/orxonox/OrxonoxPrereqs.h	(revision 9403)
+++ code/branches/shaders/src/orxonox/OrxonoxPrereqs.h	(revision 9407)
@@ -76,4 +76,5 @@
     class PlayerManager;
     class Radar;
+    class RenderQueueListener;
     class Scene;
 
Index: code/branches/shaders/src/orxonox/RenderQueueListener.cc
===================================================================
--- code/branches/shaders/src/orxonox/RenderQueueListener.cc	(revision 9407)
+++ code/branches/shaders/src/orxonox/RenderQueueListener.cc	(revision 9407)
@@ -0,0 +1,68 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder (physics)
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "RenderQueueListener.h"
+
+#include <OgreRoot.h>
+#include <OgreRenderQueueListener.h>
+
+namespace orxonox
+{
+    void RenderQueueListener::renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation)
+    {
+        if (queueGroupId == RENDER_QUEUE_STENCIL_OBJECTS)
+        { 
+            Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 
+
+            renderSystem->clearFrameBuffer(Ogre::FBT_STENCIL); 
+            renderSystem->setStencilCheckEnabled(true); 
+            renderSystem->setStencilBufferParams(Ogre::CMPF_ALWAYS_PASS,
+                STENCIL_VALUE_FOR_GLOW, STENCIL_FULL_MASK, 
+                Ogre::SOP_KEEP,Ogre::SOP_KEEP,Ogre::SOP_REPLACE,false);       
+        } 
+        if (queueGroupId == RENDER_QUEUE_STENCIL_GLOW)
+        { 
+              Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 
+              renderSystem->setStencilCheckEnabled(true); 
+              renderSystem->setStencilBufferParams(Ogre::CMPF_NOT_EQUAL,
+                  STENCIL_VALUE_FOR_GLOW, STENCIL_FULL_MASK, 
+                  Ogre::SOP_KEEP,Ogre::SOP_KEEP,Ogre::SOP_REPLACE,false);       
+        }
+    }
+   
+    void RenderQueueListener::renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation)
+    {
+        if (queueGroupId == RENDER_QUEUE_STENCIL_LAST) 
+        {
+            Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 
+            renderSystem->setStencilCheckEnabled(false); 
+            renderSystem->setStencilBufferParams(); 
+        }
+    }
+}
Index: code/branches/shaders/src/orxonox/RenderQueueListener.h
===================================================================
--- code/branches/shaders/src/orxonox/RenderQueueListener.h	(revision 9407)
+++ code/branches/shaders/src/orxonox/RenderQueueListener.h	(revision 9407)
@@ -0,0 +1,60 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder (physics)
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ORenderQueueListener_H__
+#define _ORenderQueueListener_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgreRenderQueueListener.h>
+
+namespace orxonox
+{
+    /* Defining some render queue groups based around the main render queue to enable a stenicl buffer based glow effect */
+    enum RenderQueueGroupID
+    {
+        RENDER_QUEUE_MAIN = Ogre::RENDER_QUEUE_MAIN,
+        RENDER_QUEUE_STENCIL_OBJECTS = RENDER_QUEUE_MAIN+1,
+        RENDER_QUEUE_STENCIL_GLOW = RENDER_QUEUE_MAIN+2,
+        RENDER_QUEUE_STENCIL_LAST = RENDER_QUEUE_STENCIL_GLOW
+    };
+
+    const int STENCIL_VALUE_FOR_GLOW = 1; //if more than one type of stencil mask is to be used it needs to use another value
+    const int STENCIL_FULL_MASK = 0xFFFFFFFF;
+    
+    /* Deriving from the Ogre RenderQueueListener to define our own handling of the different rendering stages to enable alpha based shader/glow effects */
+    class _OrxonoxExport RenderQueueListener : public Ogre::RenderQueueListener
+    {
+        public:
+            virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation);
+            virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation);
+    };
+}
+
+#endif /* _ORenderQueueListener_H__ */
Index: code/branches/shaders/src/orxonox/Scene.cc
===================================================================
--- code/branches/shaders/src/orxonox/Scene.cc	(revision 9403)
+++ code/branches/shaders/src/orxonox/Scene.cc	(revision 9407)
@@ -48,4 +48,5 @@
 #include "worldentities/WorldEntity.h"
 #include "Level.h"
+#include "RenderQueueListener.h"
 
 namespace orxonox
@@ -66,4 +67,6 @@
             this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
             this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
+            RenderQueueListener* renderQueueListener = new RenderQueueListener();
+            this->sceneManager_->addRenderQueueListener(renderQueueListener);//add our own renderQueueListener
 
             this->radar_ = new Radar();
Index: code/branches/shaders/src/orxonox/graphics/Model.cc
===================================================================
--- code/branches/shaders/src/orxonox/graphics/Model.cc	(revision 9403)
+++ code/branches/shaders/src/orxonox/graphics/Model.cc	(revision 9407)
@@ -44,5 +44,5 @@
 
     Model::Model(BaseObject* creator) :
-        StaticEntity(creator), bCastShadows_(true), lodLevel_(5), bLodEnabled_(true), numLodLevels_(10), lodReductionRate_(.15f)
+        StaticEntity(creator), bCastShadows_(true), renderQueueGroup_(RENDER_QUEUE_STENCIL_OBJECTS), lodLevel_(5), bLodEnabled_(true), numLodLevels_(10), lodReductionRate_(.15f)
     {
         RegisterObject(Model);
@@ -71,4 +71,5 @@
 
         XMLPortParam(Model, "mesh", setMeshSource, getMeshSource, xmlelement, mode);
+        XMLPortParam(Model, "renderQueueGroup", setRenderQueueGroup, getRenderQueueGroup, xmlelement, mode);
         XMLPortParam(Model, "material", setMaterial, getMaterial, xmlelement, mode);
         XMLPortParam(Model, "shadow", setCastShadows, getCastShadows, xmlelement, mode).defaultValues(true);
@@ -78,4 +79,6 @@
     {
         registerVariable(this->meshSrc_,    VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedMesh));
+        registerVariable(this->renderQueueGroup_,    VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedRenderQueueGroup));
+        registerVariable(this->materialName_,    VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedMaterial));
         registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedShadows));
     }
@@ -108,4 +111,15 @@
                 if (this->bGlobalEnableLod_)
                     this->enableLod();
+            }
+        }
+    }
+
+    void Model::changedRenderQueueGroup()
+    {
+        if (GameMode::showsGraphics())
+        {
+            if (this->mesh_.getEntity())
+            {
+                this->mesh_.getEntity()->setRenderQueueGroup(this->renderQueueGroup_);
             }
         }
Index: code/branches/shaders/src/orxonox/graphics/Model.h
===================================================================
--- code/branches/shaders/src/orxonox/graphics/Model.h	(revision 9403)
+++ code/branches/shaders/src/orxonox/graphics/Model.h	(revision 9407)
@@ -34,4 +34,5 @@
 #include <string>
 #include "tools/Mesh.h"
+#include "RenderQueueListener.h"
 #include "worldentities/StaticEntity.h"
 
@@ -58,4 +59,10 @@
                 { return this->meshSrc_; }
 
+            //TODO: let this function accept strings instead of ints for the XML Port, so we don't have to rely on static int values which may change in future Ogre revisions
+            inline void setRenderQueueGroup(const int renderQueueGroup)
+                { this->renderQueueGroup_ = renderQueueGroup; this->changedRenderQueueGroup(); }
+            inline const int getRenderQueueGroup() const
+                { return this->renderQueueGroup_; }
+
             inline void setCastShadows(bool bCastShadows)
                 { this->bCastShadows_ = bCastShadows; this->changedShadows(); }
@@ -71,4 +78,5 @@
             void registerVariables();
             void changedMesh();
+            void changedRenderQueueGroup();
             void changedMaterial();
             void changedShadows();
@@ -86,4 +94,5 @@
             Mesh mesh_;
             bool bCastShadows_;
+            int renderQueueGroup_;
             std::string materialName_;
 
