Index: code/branches/environment2/WorldEntityShader.cpp
===================================================================
--- code/branches/environment2/WorldEntityShader.cpp	(revision 8557)
+++ code/branches/environment2/WorldEntityShader.cpp	(revision 8557)
@@ -0,0 +1,37 @@
+/*
+ *   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:
+ *      Markus 'atok' Wegmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ Contains the implementation of the WorldEntityShader class.
+ 
+ @see WorldEntityShader.h
+**/
+
+
+#include "WorldEntityShader.h"
Index: code/branches/environment2/src/libraries/tools/Shader.h
===================================================================
--- code/branches/environment2/src/libraries/tools/Shader.h	(revision 8497)
+++ code/branches/environment2/src/libraries/tools/Shader.h	(revision 8557)
@@ -89,9 +89,13 @@
             inline Ogre::SceneManager* getSceneManager() const
                 { return this->scenemanager_; }
-
+            
+            /// Returns the compositor instance. Normally used for manually modifiying compositor parameters, when mt-type conversatio.
+            inline Ogre::CompositorInstance* getMutableCompositorInstance()
+                { return this->compositorInstance_; }
+        
             virtual void cameraChanged(Ogre::Viewport* viewport, Ogre::Camera* oldCamera);
 
+            void setParameter(size_t technique, size_t pass, const std::string& parameter, int value);
             void setParameter(size_t technique, size_t pass, const std::string& parameter, float value);
-            void setParameter(size_t technique, size_t pass, const std::string& parameter, int value);
 
             virtual void notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr& materialPtr);
Index: code/branches/environment2/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/environment2/src/orxonox/OrxonoxPrereqs.h	(revision 8497)
+++ code/branches/environment2/src/orxonox/OrxonoxPrereqs.h	(revision 8557)
@@ -111,5 +111,5 @@
     class FadingBillboard;
     class GlobalShader;
-    class GlobalGodrayShader;
+    class GodrayShader;
     class Light;
     class Model;
Index: code/branches/environment2/src/orxonox/graphics/CMakeLists.txt
===================================================================
--- code/branches/environment2/src/orxonox/graphics/CMakeLists.txt	(revision 8497)
+++ code/branches/environment2/src/orxonox/graphics/CMakeLists.txt	(revision 8557)
@@ -4,5 +4,5 @@
   FadingBillboard.cc
   GlobalShader.cc
-  GlobalGodrayShader.cc
+  GodrayShader.cc
   MeshLodInformation.cc
   Model.cc
@@ -10,4 +10,5 @@
   ParticleEmitter.cc
   ParticleSpawner.cc
+  WorldEntityShader.cc
 COMPILATION_BEGIN GraphicsCompilation.cc
   Backlight.cc
Index: code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.cc
===================================================================
--- code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.cc	(revision 8497)
+++ 	(revision )
@@ -1,106 +1,0 @@
-/*
- *   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:
- *      Markus 'atok' Wegmann
- *   Co-authors:
- *      ...
- *
- */
-
-/**
- @file
- 
- @brief Implementation of the GlobalGodrayShader class.
- */
-
-#include "GlobalGodrayShader.h"
-
-#include "util/Exception.h"
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-namespace orxonox
-{
-    CreateFactory(GlobalGodrayShader);
-    
-    GlobalGodrayShader::GlobalGodrayShader(BaseObject* creator) : BaseObject(creator), globalShader_(creator)
-    {
-        RegisterObject(GlobalGodrayShader);
-        
-        if (!this->getScene())
-            ThrowException(AbortLoading, "Can't create GlobalGodrayShader, no scene given.");
-        //        if (!this->getScene()->getSceneManager())
-        //            ThrowException(AbortLoading, "Can't create GlobalGodrayShader, no scene manager given.");
-        
-        this->skyColor_ = ColourValue::Black;
-        this->exposure_ = 1.0f;
-        this->decay_ = 0.1f;
-        this->density_ = 0.7f;
-        
-        //// Init ////
-    }
-    
-    GlobalGodrayShader::~GlobalGodrayShader()
-    {
-        this->setVisible(false);
-    }
-    
-    void GlobalGodrayShader::tick(float dt)
-    {
-        // To-Do
-    }
-    
-    void GlobalGodrayShader::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(GlobalGodrayShader, XMLPort, xmlelement, mode);
-        
-        XMLPortParamTemplate(GlobalGodrayShader, "sunPosition", setSunPosition, getSunPosition, xmlelement, mode, const Vector3&);
-        XMLPortParamTemplate(GlobalGodrayShader, "skyColor", setSkyColor, getSkyColor, xmlelement, mode, const ColourValue&);
-        XMLPortParamVariable(GlobalGodrayShader, "exposure", exposure_, xmlelement, mode);
-        XMLPortParamVariable(GlobalGodrayShader, "decay", decay_, xmlelement, mode);
-        XMLPortParamVariable(GlobalGodrayShader, "density", density_, xmlelement, mode);
-    }
-    
-    void GlobalGodrayShader::setSunPosition(const Vector3& position)
-    {
-        this->sunPosition_ = position;
-    }
-    void GlobalGodrayShader::setSkyColor(const ColourValue& color)
-    {
-        this->skyColor_ = color;
-    }
-    const Vector3& GlobalGodrayShader::getSunPosition() const
-    {
-        return this->sunPosition_;
-    }
-    const ColourValue& GlobalGodrayShader::getSkyColor() const
-    {
-        return this->skyColor_;
-    }
-    
-    void GlobalGodrayShader::changedVisibility()
-    {
-        SUPER(GlobalGodrayShader, changedVisibility);
-        
-        this->globalShader_.setVisible(this->isVisible());
-    }
-}
Index: code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.h
===================================================================
--- code/branches/environment2/src/orxonox/graphics/GlobalGodrayShader.h	(revision 8497)
+++ 	(revision )
@@ -1,86 +1,0 @@
-/*
- *   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:
- *      Markus 'atok' Wegmann
- *   Co-authors:
- *      ...
- *
- */
-
-
-/**
- @file
- 
- @brief Header of the GlobalGodrayShader class.
-*/
-
-
-#ifndef _GlobalGodrayShader_H__
-#define _GlobalGodrayShader_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "tools/interfaces/Tickable.h"
-#include "core/BaseObject.h"
-#include "util/Math.h"
-#include "GlobalShader.h"
-
-
-namespace orxonox
-{
-    /**
-     @brief 
-     
-    */
-    class _OrxonoxExport GlobalGodrayShader : public BaseObject, public Tickable
-    {
-        public:
-            GlobalGodrayShader(BaseObject* creator);
-            virtual ~GlobalGodrayShader();
-            
-            virtual void tick(float dt);
-            
-            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-        
-            virtual void changedVisibility();
-            
-            inline const GlobalShader& getGlobalShader() const
-            { return this->globalShader_; }
-        
-            void setSunPosition(const Vector3& position);
-            void setSkyColor(const ColourValue& color);
-            const Vector3& getSunPosition() const;
-            const ColourValue& getSkyColor() const;
-        
-        private:
-            
-            GlobalShader globalShader_;
-            
-            Vector3 sunPosition_;
-            ColourValue skyColor_;
-            float exposure_;
-            float decay_;
-            float density_;
-    };
-}
-
-#endif /* _GlobalGodrayShader_H__ */
Index: code/branches/environment2/src/orxonox/graphics/GlobalShader.h
===================================================================
--- code/branches/environment2/src/orxonox/graphics/GlobalShader.h	(revision 8497)
+++ code/branches/environment2/src/orxonox/graphics/GlobalShader.h	(revision 8557)
@@ -50,4 +50,7 @@
             inline const Shader& getShader() const
                 { return this->shader_; }
+        
+            inline Shader& getMutableShader()
+                { return this->shader_; }
 
         private:
Index: code/branches/environment2/src/orxonox/graphics/GodrayShader.cc
===================================================================
--- code/branches/environment2/src/orxonox/graphics/GodrayShader.cc	(revision 8557)
+++ code/branches/environment2/src/orxonox/graphics/GodrayShader.cc	(revision 8557)
@@ -0,0 +1,126 @@
+/*
+ *   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:
+ *      Markus 'atok' Wegmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+ 
+ @brief Implementation of the GodrayShader class.
+ */
+
+
+#include "GodrayShader.h"
+
+#include "util/Exception.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    CreateFactory(GodrayShader);
+    
+    GodrayShader::GodrayShader(BaseObject* creator) : BaseObject(creator), globalShader_(creator)
+    {
+        RegisterObject(GodrayShader);
+        
+        // Default parameters are initialized
+        this->sunPosition_ = Vector3::Zero;
+        this->sunColor_ = ColourValue::White;
+        this->skyColor_ = ColourValue::Black;
+        this->exposure_ = 1.0f; 
+        this->decay_ = 0.1f;
+        this->density_ = 0.7f;
+        
+        // Godrays.compositor is getting initialized
+        this->globalShader_.getMutableShader().setCompositorName("Godrays");
+        this->compositor_ = this->globalShader_.getMutableShader().getMutableCompositorInstance();
+    }
+    
+    GodrayShader::~GodrayShader()
+    {
+        this->setVisible(false);
+    }
+    
+    void GodrayShader::tick(float dt)
+    {
+        if(this->isVisible())
+        {
+            
+            //Reset sunPosition in the compositor instance every tick
+            this->compositor_->getTechnique()->getTargetPass(2)
+        }
+    }
+    
+    void GodrayShader::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(GodrayShader, XMLPort, xmlelement, mode);
+        
+        XMLPortParamTemplate(GodrayShader, "sunColor", setSunColor, getSunColor, xmlelement, mode, const ColourValue&);
+        XMLPortParamTemplate(GodrayShader, "skyColor", setSkyColor, getSkyColor, xmlelement, mode, const ColourValue&);
+        XMLPortParamVariable(GodrayShader, "exposure", exposure_, xmlelement, mode);
+        XMLPortParamVariable(GodrayShader, "decay", decay_, xmlelement, mode);
+        XMLPortParamVariable(GodrayShader, "density", density_, xmlelement, mode);
+    }
+    
+    void GodrayShader::setWorldEntity(WorldEntity* worldEntity)
+    {
+        this->worldEntity_ = worldEntity;
+        this->setSunPosition(worldEntity->getWorldPosition());
+    }
+    
+    void GodrayShader::setSunPosition(const Vector3& position)
+    {
+        this->sunPosition_ = position;
+    }
+    void GodrayShader::setSunColor(const ColourValue& color)
+    {
+        this->skyColor_ = color;
+    }
+    void GodrayShader::setSkyColor(const ColourValue& color)
+    {
+        this->skyColor_ = color;
+    }
+    const Vector3& GodrayShader::getSunPosition() const
+    {
+        return this->sunPosition_;
+    }
+    const ColourValue& GodrayShader::getSunColor() const
+    {
+        return this->sunColor_;
+    }
+    const ColourValue& GodrayShader::getSkyColor() const
+    {
+        return this->skyColor_;
+    }
+    
+    void GodrayShader::changedVisibility()
+    {
+        SUPER(GodrayShader, changedVisibility);
+        
+        this->globalShader_.setVisible(this->isVisible());
+    }
+}
Index: code/branches/environment2/src/orxonox/graphics/GodrayShader.h
===================================================================
--- code/branches/environment2/src/orxonox/graphics/GodrayShader.h	(revision 8557)
+++ code/branches/environment2/src/orxonox/graphics/GodrayShader.h	(revision 8557)
@@ -0,0 +1,97 @@
+/*
+ *   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:
+ *      Markus 'atok' Wegmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+/**
+ @file
+ 
+ @brief Header of the GodrayShader class.
+*/
+
+
+#ifndef _GodrayShader_H__
+#define _GodrayShader_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgreCompositorInstance.h>
+
+#include "tools/interfaces/Tickable.h"
+#include "core/BaseObject.h"
+#include "util/Math.h"
+#include "WorldEntity.h"
+#include "GlobalShader.h"
+
+
+namespace orxonox
+{
+    /**
+     @brief 
+     
+    */
+    class _OrxonoxExport GodrayShader : public BaseObject, public Tickable
+    {
+        public:
+            GodrayShader(BaseObject* creator);
+            virtual ~GodrayShader();
+            
+            virtual void tick(float dt);
+        
+            virtual void updateParameters();
+            
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+        
+            virtual void changedVisibility();
+        
+            void setWorldEntity(WorldEntity* worldEntity);
+            
+            inline const GlobalShader& getGlobalShader() const
+            { return this->globalShader_; }
+        
+            void setSunPosition(const Vector3& position);
+            void setSunColor(const ColourValue& color);
+            void setSkyColor(const ColourValue& color);
+            const Vector3& getSunPosition() const;
+            const ColourValue& getSunColor() const;
+            const ColourValue& getSkyColor() const;
+        
+        private:
+        
+            WorldEntity* worldEntity_;
+            GlobalShader globalShader_;
+            Ogre::CompositorInstance* compositor_;
+            Vector3 sunPosition_;
+            ColourValue sunColor_;
+            ColourValue skyColor_;
+            float exposure_;
+            float decay_;
+            float density_;
+    };
+}
+
+#endif /* _GodrayShader_H__ */
Index: code/branches/environment2/src/orxonox/graphics/WorldEntityShader.h
===================================================================
--- code/branches/environment2/src/orxonox/graphics/WorldEntityShader.h	(revision 8557)
+++ code/branches/environment2/src/orxonox/graphics/WorldEntityShader.h	(revision 8557)
@@ -0,0 +1,44 @@
+/*
+ *   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:
+ *      Markus 'atok' Wegmann
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+ @file
+    Contains the header of the WorldEntityShader class.
+ @brief
+    WorldEntityShader will be used in the future for "non-material" shaders that depend on WorldEntity data of the creator (such as their world position, orientation, etc.). "Non-material" means that they are not depending on a polygon-mesh of the creator (but can), simply rendering them. Therefore its best purpose is to implement screenspace-effects (e.g. Compositor).
+    Motivation & Advantages: 
+        - WorldEntityShader's classes can be initalized and attached in every other WorldEntity object by XML. This makes leveldesign much more easy.
+        - No id managment of the creators has to be done. Everything can be nested.
+    
+    Case scenarios would be coronas (position), godrays, etc.
+ 
+    Some sort of implementation already exists: The GodrayShader class uses the same approach. It can be used as a (raw) template.
+ **/
+
+
+        
Index: code/branches/environment2/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/branches/environment2/src/orxonox/worldentities/WorldEntity.cc	(revision 8497)
+++ code/branches/environment2/src/orxonox/worldentities/WorldEntity.cc	(revision 8557)
@@ -177,4 +177,6 @@
         // Attached collision shapes
         XMLPortObject(WorldEntity, CollisionShape, "collisionShapes", attachCollisionShape, getAttachedCollisionShape, xmlelement, mode);
+        // Attach WorldEntityShaders that depend on WorldEntity data (e.g. position). -- TODO -- Extend to WorldEntityShader.
+        XMLPortObject(WorldEntity, GodrayShader, "shaders", attachShader, getAttachedObject, xmlelement, mode);
     }
 
@@ -510,4 +512,28 @@
         return 0;
     }
+    
+    void WorldEntity::attachShader(GodrayShader* object)
+    {
+        object->setWorldEntity(object);
+        
+        this->shaders_.insert(object);
+    }
+    void WorldEntity::detachShader(GodrayShader* object)
+    {
+        std::set<WorldEntity*>::iterator it = this->children_.find(object);
+        this->shaders_.erase(it);
+        
+    }
+    GodrayShader* WorldEntity::getAttachedShader(unsigned int index)
+    {
+        unsigned int i = 0;
+        for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)
+        {
+            if (i == index)
+                return (*it);
+            ++i;
+        }
+        return 0;
+    }
 
     //! Attaches an Ogre::SceneNode to this WorldEntity.
Index: code/branches/environment2/src/orxonox/worldentities/WorldEntity.h
===================================================================
--- code/branches/environment2/src/orxonox/worldentities/WorldEntity.h	(revision 8497)
+++ code/branches/environment2/src/orxonox/worldentities/WorldEntity.h	(revision 8557)
@@ -199,4 +199,10 @@
             void attachToNode(Ogre::SceneNode* node);
             void detachFromNode(Ogre::SceneNode* node);
+            
+            void attachShader(GodrayShader* object);
+            void detachShader(GodrayShader* object);
+            GodrayShader* getAttachedShader(unsigned int index);
+            inline const std::set<WorldEntity*>& getAttachedShaders() const
+            { return this->shaders_; }
 
             inline void setDeleteWithParent(bool value)
@@ -234,4 +240,5 @@
             unsigned int parentID_;
             std::set<WorldEntity*> children_;
+            std::set<WorldEntity*> shaders_;
             bool bDeleteWithParent_;
 
