Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreSharedRuns.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreSharedRuns.h	(revision 790)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreSharedRuns.h	(revision 1055)
@@ -6,4 +6,17 @@
 using namespace Ogre;
 
+enum GlobalTargetType
+{
+	ILLUM_GLOBAL_TARGET_FIREPARTICLES
+};
+
+class GlobalUseRenderTarget
+{
+public:
+	GlobalUseRenderTarget(){lastUpdated = 0; renderTarget = 0;}
+	
+	unsigned long lastUpdated;
+	RenderTarget* renderTarget;
+};
 /**
 	@brief Class of SharedRuns used in an OGRE environment.	
@@ -112,5 +125,5 @@
 		@param r2 pointer to the other SharedRuns instance
 	*/
-	static bool haveCommonRuns(SharedRuns* r1, SharedRuns* r2);
+	static bool haveCommonRuns(SharedRuns* r1, SharedRuns* r2, std::vector<RenderingRunType>& commonruns);
 	/**
 		@brief Checks if this node has a resource with the given type.
@@ -170,6 +183,17 @@
 	//inherited
 	void destroy();
+	void runUpdated(RenderingRunType runType, RenderingRun* run);
+	void runChanged(RenderingRunType runType, RenderingRun* run);
+	virtual void addTechniqueGroup(TechniqueGroup* group){childTechniqueGroups.push_back(group);}
 	
 protected:
+	/**
+		@brief child TechniqueGroup instance.
+
+		If this SharedRuns node is a leaf, it containes a reference to a TechniqueGroup instance.
+		All messages will be transfered to this object, 
+		and bounding information will be retrieved from this TechniqueGroup
+	*/
+	std::vector<TechniqueGroup*> childTechniqueGroups;
 	/**
 		@brief map of contained RenderingRuns
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h	(revision 949)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h	(revision 1055)
@@ -13,4 +13,5 @@
 #include "OgreDepthShadowMapRenderingRun.h"
 #include "OgreDepthShadowRecieverRenderTechnique.h"
+#include "OgreFireRenderTechnique.h"
 
 
@@ -51,4 +52,6 @@
 	*/
 	BillboardSet* findRenderableInParticleSystem(ParticleSystem* system);
+	void preAllUpdates();
+	void postAllUpdates();
 
 	/**
@@ -62,4 +65,5 @@
 	*/
 	float maxRad;
+	std::map<RenderingRunType,float> maxRads;
 	/**
 		@brief The camera attached to the player.
@@ -106,7 +110,11 @@
 	std::map<String, OgreSharedRuns*> perLightRuns;
 
-	
+	std::map<GlobalTargetType, GlobalUseRenderTarget*> globalTargets;
+
+	std::vector<UpdateListener*> updateListeners;
+
 public:
 
+	void addUpdateListener(UpdateListener* l){updateListeners.push_back(l);}
 	/**
 		@brief registers a RenderTechniqueFactory
@@ -120,8 +128,23 @@
 	*/
 	float getMaxJoinRadius(){return maxRad;}
+	float getMaxJoinRadius(RenderingRunType type){return maxRads[type];}
 	/**
 		@brief sets the maximum bounding sphere radius with two SharedRuns can be joined.
 	*/
-	void setMaxJoinRadius(float rad){maxRad = rad;}
+	void setMaxJoinRadius(float rad)
+	{
+		std::map<RenderingRunType,float> ::iterator it = maxRads.begin();
+		std::map<RenderingRunType,float> ::iterator itend = maxRads.end();
+		
+		maxRad = rad;
+	
+		while(it != itend)
+		{
+			(*it).second = maxRad;
+			it++;
+		}
+		
+	}
+	void setMaxJoinRadius(RenderingRunType type, float rad){maxRads[type] = rad;}
 	/**
 		@brief Returns the one and only OgreIlluminationManager instance.
@@ -146,4 +169,8 @@
 	*/
 	void initTechniques(Entity* e);
+	/**
+		@brief searches for RenderTechniques in materials and creates them for a Billboardset.
+	*/
+	void initTechniques(BillboardSet* bbs, ParticleSystem* sys);
 	/**
 		@brief Returns a pointer to the player camera.
@@ -224,4 +251,7 @@
 	*/
 	RenderingRun* getGlobalRun(RenderingRunType runType);
+
+	GlobalUseRenderTarget* getGlobalTarget(GlobalTargetType type);
+	void addGlobalTarget(GlobalTargetType type, GlobalUseRenderTarget* target);
 	/**
 		@brief Updates a global RenderingRun with the given type.
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 808)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 1055)
@@ -30,4 +30,6 @@
 	*/
 	OgreRenderingRun* asOgreRenderingRun(){return this;}
+
+	virtual bool canJoin(OgreRenderingRun* run){return true;}
 
 protected:
@@ -66,5 +68,5 @@
 		@see renderPixelSprites
 	*/
-	SpriteSet* pixelSprites;
+	BillboardSet* pixelSprites;
 	/**
 		@brief unique name of the SpriteSet used in pixel sprite rendering
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePhotonMapRenderingRun.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePhotonMapRenderingRun.h	(revision 949)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePhotonMapRenderingRun.h	(revision 1055)
@@ -48,5 +48,11 @@
 	void refreshLight();
 
-	
+	bool canJoin(OgreRenderingRun* run)
+	{
+		OgrePhotonMapRenderingRun* r = (OgrePhotonMapRenderingRun*) run;
+		if(r->materialName == materialName)
+			return true;
+		return false;
+	}
 	void distanceCubeMapChanged(RenderingRun* run);
 	
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreCausticCubeMapRenderingRun.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreCausticCubeMapRenderingRun.h	(revision 790)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreCausticCubeMapRenderingRun.h	(revision 1055)
@@ -40,5 +40,6 @@
 								 String materialName,
 								 unsigned char photonMapTexId,
-								 bool updateAllFace
+								 bool updateAllFace,
+								 float attenuation
 								 );
 	/**
@@ -49,5 +50,14 @@
 	//inherited
 	void photonMapChanged(RenderingRun* run);
+	float getAttenuation(){return attenuation;}
 	
+	bool canJoin(OgreRenderingRun* run)
+	{
+		OgreCausticCubeMapRenderingRun* r = (OgreCausticCubeMapRenderingRun*) run;
+		if(r->materialName == materialName)
+			return true;
+		return false;
+	}
+
 protected:
 	/**
@@ -71,4 +81,5 @@
 	*/
 	String materialName;
+	float attenuation;
 	
 	//inherited
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreChildPSystemRenderingRun.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreChildPSystemRenderingRun.h	(revision 1055)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreChildPSystemRenderingRun.h	(revision 1055)
@@ -0,0 +1,83 @@
+#pragma once
+
+//disable inheritance warning caused by multiple inheritance
+#if _WIN32
+#if _MSC_VER
+#pragma warning(disable: 4250)
+#endif
+#endif
+
+#include "OgreRenderingRun.h"
+#include "ChildPSystemRenderingRun.h"
+#include "OgreSharedRuns.h"
+
+
+/**
+	@brief ColorCubeMapRenderingRun used in an OGRE environment.
+*/
+class OgreChildPSystemRenderingRun : public OgreRenderingRun,
+									public ChildPsystemRenderingRun
+{	
+public:
+
+	/**
+		@brief Constructor.
+
+		@param sharedRuns			a pointer to the OgreSharedRuns this run belongs to
+		@param name					the name of the texture to be created
+		@param startFrame			adds an offset to the current frame number to help evenly distribute updates between frames
+		@param updateInterval		update frequency
+		@param materialName			the name of the material should be used when rendering the choton hit map
+*/	
+	OgreChildPSystemRenderingRun(OgreSharedRuns* sharedRuns,
+								String name,
+								unsigned long startFrame,
+								unsigned long updateInterval,
+								unsigned int resolution,
+								bool perspectiveRendering,
+								String childParticleSystemName,
+								String particleScriptName,
+								bool useOwnMaterial,
+								String materialName
+								);
+	/**
+		@brief returns the name of the resulting photon hit map
+	*/
+	String getImpostorTextureName(){return name;}
+	
+	bool canJoin(OgreRenderingRun* run)
+	{
+		
+		return false;
+	}
+	
+protected:	
+	bool perspectiveRendering;
+	bool useOwnMaterial;
+	String materialName;
+	String childParticleSystemName;
+	String particleScriptName;
+	/**
+		@brief the created photon hit map texture
+	*/
+	Camera* impostorCamera;
+	/**
+		@brief a pointer to the OgreSharedRuns this run belongs to
+	*/
+	OgreSharedRuns* sharedRuns;
+	/**
+		@brief the name of the photonmap texture that was created by this run
+	*/
+	String name;
+	/**
+		@brief a pointer to the photonmap texture that was created by this run
+	*/
+	Texture* impostorTexture;
+	
+
+	//inherited
+	void updateFrame(unsigned long frameNum);	
+	//inherited
+	inline void createImpostorTexture();
+
+};
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDepthShadowMapRenderingRun.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDepthShadowMapRenderingRun.h	(revision 790)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDepthShadowMapRenderingRun.h	(revision 1055)
@@ -41,5 +41,5 @@
 		@brief returns the depth shadow map texture created by this run
 	*/
-	String getDepthMapTextureName(){return name;}
+	String getDepthMapTextureName(int i){return names[i];}
 	/**
 		@brief Refreshes light camera matrices, called in each update.
@@ -49,9 +49,9 @@
 		@brief retuns the view matrix of the camera from which the depth shadow map was created
 	*/
-	Matrix4 getLightViewMatrix();
+	Matrix4 getLightViewMatrix(int i);
 	/**
 		@brief retuns the concatenation of the view and projection matrices of the camera from which the depth shadow map was created
 	*/
-	Matrix4 getLightViewProjMatrix();
+	Matrix4 getLightViewProjMatrix(int i);
 
 protected:	
@@ -63,5 +63,5 @@
 		@brief pointer to the camera of the lightsource
 	*/
-	Camera* depthMapCamera;
+	Camera* depthMapCameras[2];
 	/**
 		@brief the name of the material to be used when rendering the depth shadow map
@@ -75,9 +75,9 @@
 		@brief the name of the depth shadow map texture that was created by this run
 	*/
-	String name;
+	String names[2];
 	/**
 		@brief a pointer to the depth shadow texture that was created by this run
 	*/
-	Texture* depthMapTexture;
+	Texture* depthMapTextures[2];
 	
 	//inherited
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/Másolat - OgreRenderingRun.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/Másolat - OgreRenderingRun.h	(revision 1055)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/Másolat - OgreRenderingRun.h	(revision 1055)
@@ -0,0 +1,157 @@
+#pragma once
+#include "RenderingRun.h"
+#include "Ogre.h"
+#include "SpriteSet.h"
+
+using namespace Ogre;
+
+/**
+	@brief Base class of a RenderingRun in an OGRE environment.	
+*/
+class OgreRenderingRun : virtual public RenderingRun
+{	
+public:	
+	/**
+		@brief Constructor.
+		
+		@param startFrame			adds an offset to the current frame number to help evenly distribute updates between frames
+		@param updateInterval		photon map update frequency		
+	*/
+	OgreRenderingRun(unsigned long startFrame,
+					unsigned long updateInterval)
+						:RenderingRun(startFrame, updateInterval)
+	{
+		pixelSprites = 0;
+	}
+	/**
+		@brief Conversion to OgreRenderRun.
+
+		This function is needed because of virtual inheritance.
+	*/
+	OgreRenderingRun* asOgreRenderingRun(){return this;}
+
+protected:
+
+	/**
+		@brief map of Renderables which will be rendered with a given material
+
+		The String stores the original material name that will be restored after rendering.
+
+		@see setMaterialForVisibles
+		@see setMaterialForRenderables
+		@see restoreMaterials
+	*/
+	std::map<Renderable*, String> visibleObjects;
+	/**
+		@brief fulls screen quad plane used in full screen quad rendering
+
+		@see renderFullscreenQuad
+	*/
+	static MovablePlane* fullScreenQuad;
+	/**
+		@brief fulls screen quad Entity used in full screen quad rendering
+
+		@see renderFullscreenQuad
+	*/
+	static Entity* fullScreenQuadEntity;
+	/**
+		@brief fulls screen quad SceneNode used in full screen quad rendering
+
+		@see renderFullscreenQuad
+	*/
+	static SceneNode* fullScreenQuadNode;
+	/**
+		@brief SpriteSet used in pixel sprite rendering
+
+		@see renderPixelSprites
+	*/
+	SpriteSet* pixelSprites;
+	/**
+		@brief unique name of the SpriteSet used in pixel sprite rendering
+
+		@see renderPixelSprites
+	*/
+	String spriteSetName;
+
+	/**
+		@brief Returns a direction for a cubemap face id.
+
+		This is a helper function to retrieve the normal direction of a given 
+		cubemap face.
+
+		@param faceId the number of the face
+	*/
+	Vector3 getCubeMapFaceDirection(unsigned char faceId);
+	/**
+		@brief Creates a cubemap texture.
+
+		This is a helper function to easily create a cubemap texture and automaticly attach
+		viewports to each face so it can be used as a rendertarget.
+
+		@param name the name of the texture to be created
+		@param position the initial position of the cubemap
+		@param resolution the resolution of one cubemapface
+		@param format the pixel format of the cubemap
+		@param numMips the number of mipmap levels
+		@param clearColor initial color
+	*/
+	Texture* createCubeRenderTexture(String name, const Vector3 position, unsigned int resolution = 512, PixelFormat format = PF_FLOAT16_RGBA, int numMips = 0, ColourValue clearColor = ColourValue::Black);
+	/**
+		@brief Sets the given material for each Renderable in a RenderQueue.
+
+		This is a helper function to set a material to each element of a previously filled Renderque.
+		The orginal material of the Renderables are stored so they can be restored later.
+		The function also tells the current SceneManager not to search for visible objects, as we are
+		going to use the given RenderQueue during the next rendering.
+
+		@param materialName the name of the material to set for the Renderables
+		@param rq pointer to the filled Renderqueue instance to set material for
+	*/
+	void setMaterialForRenderables(String& materialName, RenderQueue* rq);
+	/**
+		@brief Sets the given material for each Renderable visible from a given camera.
+
+		This helper function is similar to setMaterialForRenderables but it is also responsible for filling the RenderQueue.
+		First the RenderQueue of the current SceneManager fill be filled with the visible objects seen from the given camera.
+		Then the required material will be set for each element of the RenderQueue.
+		The orginal material of the Renderables are stored so they can be restored later.
+		The function also tells the current SceneManager not to search for visible objects, as we are
+		going to use the filled RenderQueue during the next rendering.
+
+		@param materialName the name of the material to set for the Renderables
+		@param cam pointer to the camera from which visible objects should be searched
+		@param shadowcastersonly flag to search for only shadow casters
+	*/
+	void setMaterialForVisibles(String& materialName, Camera* cam, bool shadowcastersonly = false);
+	/**
+		@brief Restores previously stored materials.
+
+		This helper function is typically used after a setMaterialForRenderables or setMaterialForVisibles
+		call and a rendering process to restore the original material settings.
+		The function also tells the current SceneManager to search for visible objects, as this is the
+		default behaviour of SceneManager.		
+	*/
+	void restoreMaterials();
+	/**
+		@brief Renderes a full screen quad on a given RendderTarget with a given material.
+
+		@param materialName the name of the material bind to the quad
+		@param target the RenderTarget the quad should be rendered on
+	*/
+	void renderFullscreenQuad(String materialName, RenderTarget* target);
+	/**
+		@brief Renderes sprites to pixels of the screen on a given RendderTarget with a given material.
+
+		Pixel sprites are pixel sized quads, placed on each pixel of the RenderTarget.
+		The number of sprites not necessary corresponds to the resolution of the rendertarget.
+		The pixel quads will evenly fill the rendertarget's area with sizes corresponding to the given resolution.
+		We can render fewer or more pixel quads than the number of pixels the rendertarget has (eg.: in case of caustic cubemap generation).
+		
+		@param materialName the name of the material bind to the pixel sprites
+		@param rt the RenderTarget the quads should be rendered on
+		@param width the desired resolution width of the sprites
+		@param height the desired resolution height of the sprites
+	*/
+	void renderPixelSprites(String& materialName, RenderTarget* rt, int width, int height);
+	
+};
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderable.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderable.h	(revision 790)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderable.h	(revision 1055)
@@ -45,5 +45,5 @@
 		@param billboardset the BillboardSet to wrap
 	*/
-	OgreRenderable(BillboardSet* billboardset);
+	OgreRenderable(BillboardSet* billboardset, ParticleSystem* sys = 0);
 	/**
 		@brief Destructor.
@@ -149,4 +149,5 @@
 	*/
 	BillboardSet* billboardSetRenderable;
+	ParticleSystem* parentParticleSystem;
 
 	/**
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderTechnique.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderTechnique.h	(revision 836)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderTechnique.h	(revision 1055)
@@ -5,4 +5,11 @@
 
 class OgreTechniqueGroup;
+
+class UpdateListener
+{
+public:
+	virtual void preAllUpdates(){}
+	virtual void postAllUpdates(){}
+};
 
 /**
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreSBBRenderTechnique.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreSBBRenderTechnique.h	(revision 836)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreSBBRenderTechnique.h	(revision 1055)
@@ -18,5 +18,8 @@
 */
 class OgreSBBRenderTechnique : public OgreRenderTechnique,
-										public SBBRenderTechnique
+										public SBBRenderTechnique,
+										public RenderTargetListener,
+										public FrameListener,
+										public UpdateListener
 {
 public:
@@ -39,4 +42,10 @@
 	//inherited
 	virtual void update(unsigned long frameNum);
+
+	void  preRenderTargetUpdate (const RenderTargetEvent &evt);
+	void  postRenderTargetUpdate (const RenderTargetEvent &evt);
+	bool  frameEnded (const FrameEvent &evt);
+	void preAllUpdates();
+	void postAllUpdates();
 	
 protected:	
@@ -45,4 +54,6 @@
 	*/
 	unsigned char depthTexID;
+
+	bool lastVisibility;
 	
 };
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreHierarchicalParticleSystemTechnique.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreHierarchicalParticleSystemTechnique.h	(revision 1055)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreHierarchicalParticleSystemTechnique.h	(revision 1055)
@@ -0,0 +1,73 @@
+#pragma once
+
+//disable inheritance warning caused by multiple inheritance
+#if _WIN32
+#if _MSC_VER
+#pragma warning(disable: 4250)
+#endif
+#endif
+
+#include "OgreRenderTechnique.h"
+#include "HierarchicalParticleSystemTechnique.h"
+
+/**
+	@brief CausticCasterRenderTechnique used in an OGRE environment.
+*/
+class OgreHierarchicalParticleSystemTechnique : public OgreRenderTechnique,
+											public HierarchicalParticleSystemTechnique
+{
+public:
+
+	OgreHierarchicalParticleSystemTechnique(unsigned long startFrame,
+							unsigned long impostorUpdateInterval,
+							unsigned int impostorResolution,
+							unsigned char impostorTexID,
+							bool useDistCalc,
+							bool perspectiveRendering,
+							String childPSysScriptName,
+							bool useOwnMaterial,
+							String impostorMaterialName,
+							Pass* pass,
+							OgreRenderable* parentRenderable,
+							OgreTechniqueGroup* parentTechniqueGroup
+							);
+	/**
+		@brief Destructor.
+	*/
+	~OgreHierarchicalParticleSystemTechnique();	
+	
+protected:
+	
+	String impostorMaterialName;
+	String childPSysScriptName;
+	String childPSysName;
+	unsigned char impostorTexID;
+	bool useOwnMaterial;
+	
+	//inherited
+	RenderingRun* createChildPSysRenderingRun();
+};
+
+class OgreHierarchicalParticleSystemTechniqueFactory : public RenderTechniqueFactory
+{
+public:
+	
+	OgreHierarchicalParticleSystemTechniqueFactory();
+
+	OgreRenderTechnique* createInstance(IllumTechniqueParams* params,
+										Pass* pass,
+										OgreRenderable* parentRenderable,
+										OgreTechniqueGroup* parentTechniqueGroup);
+
+
+	unsigned long impostorUpdateInterval;
+	unsigned int impostorResolution;
+	unsigned long startFrame;	
+	bool useDistCalc;
+	unsigned char impostorTexID;
+	bool perspectiveRendering;
+	String impostorMaterialName;
+	String childPSysScriptName;
+	bool useOwnMaterial;
+
+};
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCausticCasterRenderTechnique.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCausticCasterRenderTechnique.h	(revision 949)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCausticCasterRenderTechnique.h	(revision 1055)
@@ -43,4 +43,5 @@
 							bool updateAllFace,
 							bool useDistance,
+							float attenuation,
 							Pass* pass,
 							OgreRenderable* parentRenderable,
@@ -57,7 +58,8 @@
 	*/
 	String& getCausticCubeMapName();
+	float getAttenuation(){return attenuation;}
 
 protected:
-
+	
 	/**
 		@brief name of the created photon hit map texture
@@ -72,19 +74,20 @@
 	*/
 	unsigned char photonMapTexID;
+	float attenuation;
 	
 	//inherited
-	virtual void photonMapRunChanged(RenderingRun* run);
+	void photonMapRunChanged(RenderingRun* run);
 	//inherited	
-	virtual void causticCubeMapRunChanged(RenderingRun* run);
+	void causticCubeMapRunChanged(RenderingRun* run);
 	//inherited
-	virtual void distanceCubeMapRunChanged(RenderingRun* run);
+	void distanceCubeMapRunChanged(RenderingRun* run);
 	//inherited
 	void distanceCubeMapRunUpdated(RenderingRun* run);
 	//inherited
-	virtual RenderingRun* createPhotonMapRun();
+	RenderingRun* createPhotonMapRun();
 	//inherited
-	virtual RenderingRun* createCausticCubeMapRun();
+	RenderingRun* createCausticCubeMapRun();
 	//inherited
-	virtual RenderingRun* createDistanceCubeMapRun();
+	RenderingRun* createDistanceCubeMapRun();
 };
 
@@ -102,4 +105,5 @@
 
 
+	float attenuation;
 	unsigned long startFrame;
 	unsigned long photonMapUpdateInterval;
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreFireRenderTechnique.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreFireRenderTechnique.h	(revision 1055)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreFireRenderTechnique.h	(revision 1055)
@@ -0,0 +1,86 @@
+#pragma once
+
+//disable inheritance warning caused by multiple inheritance
+#if _WIN32
+#if _MSC_VER
+#pragma warning(disable: 4250)
+#endif
+#endif
+
+#include "OgreRenderTechnique.h"
+#include "Ogre.h"
+
+using namespace Ogre;
+
+class FireRenderTarget :  public GlobalUseRenderTarget
+{
+	
+public:
+
+	static int targetsize;
+
+	FireRenderTarget();	
+};
+
+
+
+/**
+	@brief SBBRenderTechnique used in an OGRE environment.
+*/
+class OgreFireRenderTechnique : public OgreRenderTechnique,
+									public RenderTargetListener,
+									public FrameListener,
+									public UpdateListener
+{
+public:
+	/**
+		@brief Constructor.
+
+		@param depthTexID				the id of the texture unit state the resulting
+											scene depth map should be bound to
+		@param pass						the pass to operate on			
+		@param parentRenderable			the object to operate on
+		@param parentTechniqueGroup		the TechniqueGroup this RenderedTechnique is attached to
+	*/
+	OgreFireRenderTechnique(	unsigned char depthTexID,
+							Pass* pass,
+							OgreRenderable* parentRenderable,
+							OgreTechniqueGroup* parentTechniqueGroup
+							);
+	~OgreFireRenderTechnique();
+	
+	//inherited
+	virtual void update(unsigned long frameNum);
+
+	void  preRenderTargetUpdate (const RenderTargetEvent &evt);
+	void  postRenderTargetUpdate (const RenderTargetEvent &evt);
+	bool  frameEnded (const FrameEvent &evt);
+	void preAllUpdates();
+	
+protected:	
+	/**
+		&brief the id of the texture unit state the resulting scene depth map should be bound to
+	*/
+	unsigned char depthTexID;
+	bool lastVisibility;
+	
+};
+
+
+class OgreFireRenderTechniqueFactory : public RenderTechniqueFactory
+{
+public:
+	
+	OgreFireRenderTechniqueFactory();
+
+	OgreRenderTechnique* createInstance(IllumTechniqueParams* params,
+										Pass* pass,
+										OgreRenderable* parentRenderable,
+										OgreTechniqueGroup* parentTechniqueGroup);
+
+
+	unsigned char depthTexID;
+
+};
+
+
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.vcproj
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.vcproj	(revision 808)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.vcproj	(revision 1055)
@@ -159,4 +159,10 @@
 				</File>
 				<File
+					RelativePath="..\src\RenderTechniques\OgreFireRenderTechnique.cpp">
+				</File>
+				<File
+					RelativePath="..\src\RenderTechniques\OgreHierarchicalParticleSystemTechnique.cpp">
+				</File>
+				<File
 					RelativePath="..\src\RenderTechniques\OgreSBBRenderTechnique.cpp">
 				</File>
@@ -167,4 +173,7 @@
 				<File
 					RelativePath="..\src\RenderingRuns\OgreCausticCubeMapRenderingRun.cpp">
+				</File>
+				<File
+					RelativePath="..\src\RenderingRuns\OgreChildParticlesystemRenderingRun.cpp">
 				</File>
 				<File
@@ -235,4 +244,10 @@
 				</File>
 				<File
+					RelativePath="..\include\RenderTechniques\OgreFireRenderTechnique.h">
+				</File>
+				<File
+					RelativePath="..\include\RenderTechniques\OgreHierarchicalParticleSystemTechnique.h">
+				</File>
+				<File
 					RelativePath="..\include\RenderTechniques\OgreSBBRenderTechnique.h">
 				</File>
@@ -243,4 +258,7 @@
 				<File
 					RelativePath="..\include\RenderingRuns\OgreCausticCubeMapRenderingRun.h">
+				</File>
+				<File
+					RelativePath="..\include\RenderingRuns\OgreChildPSystemRenderingRun.h">
 				</File>
 				<File
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 808)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 1055)
@@ -214,8 +214,9 @@
 		int resolutionX = width;
 		int resolutionY = height;
-		pixelSprites = new SpriteSet(spriteSetName, resolutionX * resolutionY, true);
+		pixelSprites = new BillboardSet(spriteSetName, resolutionX * resolutionY, true);
 		pixelSprites->setBillboardsInWorldSpace(true);
-		pixelSprites->setCullIndividually(false);		
-		pixelSprites->setDefaultDimensions(1.0 / (float) resolutionX, 1.0 / resolutionY);
+		pixelSprites->setCullIndividually(false);
+		pixelSprites->setPointRenderingEnabled(true);
+		//pixelSprites->setDefaultDimensions(1.0 / (float) resolutionX, 1.0 / resolutionY);
 		pixelSprites->beginBillboards();
 		for(int i = 0; i < resolutionX; i++)
@@ -223,10 +224,10 @@
 			for(int j = 0; j < resolutionY; j++)
 			{				
-				Billboard bb;
-
-				bb.setPosition(
-								( (float)i + 0.5 )/ (float) resolutionX, //position x
-								( (float)j + 0.5 )/ (float) resolutionY, //position y
- 								0);													//position z					
+				Billboard bb( Vector3(
+										( (float)i + 0.5 )/ (float) resolutionX, //position x
+										( (float)j + 0.5 )/ (float) resolutionY, //position y
+ 										0),
+							  pixelSprites);
+				bb.setDimensions(1.0 / (float) resolutionX, 1.0 / resolutionY);				
 				pixelSprites->injectBillboard(bb);				
 			}
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/Másolat - OgreRenderingRun.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/Másolat - OgreRenderingRun.cpp	(revision 1055)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/Másolat - OgreRenderingRun.cpp	(revision 1055)
@@ -0,0 +1,250 @@
+#include "OgreRenderingrun.h"
+
+MovablePlane* OgreRenderingRun::fullScreenQuad = NULL;
+Entity* OgreRenderingRun::fullScreenQuadEntity = NULL;
+SceneNode* OgreRenderingRun::fullScreenQuadNode = NULL;
+
+class MaterialSetVisitor : public QueuedRenderableVisitor
+{
+private:
+	String materialName;
+	std::map<Renderable*, String>* visibleObjects;
+public:
+    
+	MaterialSetVisitor(String& materialName, std::map<Renderable*, String>* visibleObjects)
+	{
+		this->materialName = materialName;
+		this->visibleObjects = visibleObjects;
+	}
+
+	void visit(const Renderable* r)
+	{	
+		Renderable* rend = (Renderable*) r; //sorry for removing the const
+		
+		if( visibleObjects->count(rend) == 0)
+		{
+			(*visibleObjects)[rend] = rend->getMaterial().getPointer()->getName();
+			rend->setMaterialName(materialName);
+		}
+	}
+	bool visit(const Pass* p){return true;}
+	void visit(const RenderablePass* rp){}
+
+};
+
+Vector3 OgreRenderingRun::getCubeMapFaceDirection(unsigned char faceId)
+{
+	switch(faceId)
+	{
+		case 0: //positive X
+			return Vector3(1,0,0);
+		case 1:	//negative X
+			return Vector3(-1,0,0);
+		case 2:	 //positiove Y
+			return Vector3(0,1,0);
+		case 3:	//negative Y
+			return Vector3(0,-1,0);
+		case 4:	 //positiove Z
+			return Vector3(0,0,-1);
+		case 5:	//negative Z
+			return Vector3(0,0,1);
+		default:
+			return Vector3(0,0,0);
+	}
+}
+
+Texture* OgreRenderingRun::createCubeRenderTexture(String name,  const Vector3 position, unsigned int resolution, PixelFormat format, int numMips, ColourValue clearColor)
+{
+	//create texture
+	TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(	name, 
+																			"default",
+																			TEX_TYPE_CUBE_MAP,
+																			resolution,
+																			resolution,
+																			0,
+																			numMips,
+																			format,
+																			TU_RENDERTARGET);
+	Texture* result = texPtr.getPointer();
+
+	//add viewports to faces
+	for(unsigned int i = 0; i < 6; i++)
+	{
+		Camera* cam = Root::getSingleton()._getCurrentSceneManager()
+			->createCamera(name + "CUBEMAPFACE_" + StringConverter::toString(i) + "_CAMERA");
+		
+		cam->setPosition(position);
+		cam->setAspectRatio(1);
+		cam->setFOVy(Radian(Degree(90)));
+		cam->setNearClipDistance(0.1);
+
+		//set camera orientation
+		switch(i)
+		{
+			case 2:
+				cam->setOrientation(Quaternion(Radian(Degree(90)),Vector3(1,0,0)));
+				break;
+			case 3:
+				cam->setOrientation(Quaternion(Radian(Degree(90)),Vector3(-1,0,0)));
+				break;
+			default:
+				cam->setDirection(getCubeMapFaceDirection(i));
+				break;
+		}
+
+		HardwarePixelBuffer* hpb = (result->getBuffer(i, 0)).getPointer();
+		RenderTarget* rt = hpb->getRenderTarget(0);
+		Viewport* v = rt->addViewport(cam);
+		v->setOverlaysEnabled(false);
+		rt->setAutoUpdated(false);
+
+		Root::getSingleton().getRenderSystem()->_setViewport(v);
+		Root::getSingleton().getRenderSystem()->clearFrameBuffer( FBT_COLOUR, clearColor);
+	}
+
+	return result;
+
+}
+
+void OgreRenderingRun::setMaterialForRenderables(String& materialName, RenderQueue* rq)
+{
+	RenderQueue::QueueGroupIterator queueIt = rq->_getQueueGroupIterator();
+   
+    while (queueIt.hasMoreElements())
+    {
+        RenderQueueGroup* pGroup = queueIt.getNext();
+		
+        RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator();
+
+		while (groupIt.hasMoreElements())
+		{
+			RenderPriorityGroup* pPriorityGrp = groupIt.getNext();
+			const QueuedRenderableCollection& solids = pPriorityGrp->getSolidsBasic();
+			const QueuedRenderableCollection& transparents = pPriorityGrp->getTransparents();
+			MaterialSetVisitor visitor(materialName, &visibleObjects);	
+			solids.acceptVisitor(&visitor, QueuedRenderableCollection::OM_PASS_GROUP);
+			transparents.acceptVisitor(&visitor, QueuedRenderableCollection::OM_SORT_ASCENDING);		
+		}			
+    }
+
+	//refill renderqueue	
+	rq->clear();
+
+	std::map<Renderable*, String>::iterator it = visibleObjects.begin();
+	std::map<Renderable*, String>::iterator itend = visibleObjects.end();
+
+	while(it != itend)
+	{
+		rq->addRenderable((*it).first);
+		it++;
+	}
+
+	SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
+	sm->setFindVisibleObjects(false);	
+}
+
+void OgreRenderingRun::setMaterialForVisibles(String& materialName, Camera* cam, bool shadowcastersonly)
+{
+	SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
+	
+	RenderQueue* rq = sm->getRenderQueue();
+	rq->clear();
+
+	RenderQueue::QueueGroupIterator groupIter = rq->_getQueueGroupIterator();
+	while (groupIter.hasMoreElements())
+	{
+		RenderQueueGroup* g = groupIter.getNext();
+		g->defaultOrganisationMode();
+	}
+
+	sm->_findVisibleObjects (cam, shadowcastersonly);
+	
+	setMaterialForRenderables(materialName, rq);
+}
+
+void OgreRenderingRun::restoreMaterials()
+{
+	std::map<Renderable*, String>::iterator it = visibleObjects.begin();
+	std::map<Renderable*, String>::iterator itend = visibleObjects.end();
+
+	while(it != itend)
+	{
+		((*it).first)->setMaterialName((*it).second);
+		it++;
+	}
+	
+	visibleObjects.clear();
+
+	SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
+	sm->setFindVisibleObjects(true);
+}
+
+void OgreRenderingRun::renderFullscreenQuad(String materialName, RenderTarget* target)
+{
+    SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
+			
+	if(fullScreenQuad == NULL)
+	{
+		fullScreenQuad = new MovablePlane("PASS_FULLSCREENQUAD_PLANE");
+		fullScreenQuad->d = 0;
+        fullScreenQuad->normal = Vector3::UNIT_Z;
+		MeshManager::getSingleton().createPlane("PASS_FULLSCREENQUAD_MESH", 
+            ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 
+            *fullScreenQuad, 2, 2, 
+            1, 1, true, 1, 1, 1, Vector3::UNIT_Y);
+		fullScreenQuadEntity = sm->createEntity( "PASS_FULLSCREENQUAD_ENTITY", "PASS_FULLSCREENQUAD_MESH" );
+		sm->getRootSceneNode()->attachObject(fullScreenQuadEntity);
+		fullScreenQuadEntity->setVisible(false);
+	}
+
+	fullScreenQuadEntity->setMaterialName(materialName);
+	sm->getRenderQueue()->clear();
+	sm->getRenderQueue()->addRenderable(fullScreenQuadEntity->getSubEntity(0));
+	sm->setFindVisibleObjects(false);
+	target->update();
+	sm->setFindVisibleObjects(true);
+}
+
+void OgreRenderingRun::renderPixelSprites(String& materialName, RenderTarget* rt, int width, int height)
+{
+	SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
+	
+	if(pixelSprites == 0)
+	{	
+		int resolutionX = width;
+		int resolutionY = height;
+		pixelSprites = new SpriteSet(spriteSetName, resolutionX * resolutionY, true);
+		//pixelSprites->setBillboardsInWorldSpace(true);
+		pixelSprites->setCullIndividually(false);		
+		//pixelSprites->setDefaultDimensions(1.0 / (float) resolutionX, 1.0 / resolutionY);
+		pixelSprites->beginBillboards();
+		for(int i = 0; i < resolutionX; i++)
+		{
+			for(int j = 0; j < resolutionY; j++)
+			{				
+				Billboard bb( Vector3(
+										( (float)i + 0.5 )/ (float) resolutionX, //position x
+										( (float)j + 0.5 )/ (float) resolutionY, //position y
+ 										0),
+							  pixelSprites);
+				bb.setDimensions(1.0 / (float) resolutionX, 1.0 / resolutionY);				
+				pixelSprites->injectBillboard(bb);				
+			}
+		}
+		pixelSprites->endBillboards();
+
+		sm->getRootSceneNode()->attachObject(pixelSprites);
+		
+		pixelSprites->setVisible(false);
+	}
+	
+	pixelSprites->setMaterialName(materialName);
+
+	sm->getRenderQueue()->clear();
+	sm->getRenderQueue()->addRenderable(pixelSprites);
+	sm->setFindVisibleObjects(false);
+	rt->update();
+	sm->setFindVisibleObjects(true);
+		
+}
+
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderable.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderable.cpp	(revision 790)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderable.cpp	(revision 1055)
@@ -29,8 +29,9 @@
 }
 
-OgreRenderable::OgreRenderable(BillboardSet* billboardset)
+OgreRenderable::OgreRenderable(BillboardSet* billboardset, ParticleSystem* sys)
 {
 	renderableType = OGRE_RENDERABLETYPE_BILLBOARDSET;
 	billboardSetRenderable = billboardset;
+	parentParticleSystem = sys;
 	updateBounds();
 	name = billboardset->getName();
@@ -47,8 +48,12 @@
 	{
 	 case OGRE_RENDERABLETYPE_SUBENTITY: 
-		 subEntityRenderable->setVisible(visible);
+//		 subEntityRenderable->setVisible(visible);
+		 parentEntity->setVisible(visible);
 		 break;
 	 case OGRE_RENDERABLETYPE_BILLBOARDSET:
-		 billboardSetRenderable->setVisible(visible);
+		 if(parentParticleSystem != 0)
+			 parentParticleSystem->setVisible(visible);
+		 else
+			 billboardSetRenderable->setVisible(visible);
 		 break;
 	  default:
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhotonMapRenderingRun.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhotonMapRenderingRun.cpp	(revision 949)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhotonMapRenderingRun.cpp	(revision 1055)
@@ -103,11 +103,15 @@
 			Vector3 dir = light->getDirection();
 			photonMapCamera->setDirection( dir );
-			photonMapCamera->setPosition( sharedRuns->getRootPosition(ILLUMRUN_PHOTONMAP) - dir );
-			photonMapCamera->setProjectionType(PT_ORTHOGRAPHIC);		
+			Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_PHOTONMAP).getRadius();
+			photonMapCamera->setPosition( sharedRuns->getRootPosition(ILLUMRUN_PHOTONMAP) - dir * r);
+			photonMapCamera->setProjectionType(PT_ORTHOGRAPHIC);
+			Matrix4 proj;
+			proj = Matrix4::IDENTITY;
+			proj.setScale(Vector3(1.0/r, 1.0/r, -1.0/r));
+			proj.setTrans(Vector3(0,0,-1));
+			photonMapCamera->setCustomProjectionMatrix(true,proj);
 		}
 		else
-		{
-			photonMapCamera->setFarClipDistance(100000);
-			photonMapCamera->setNearClipDistance(0.1);
+		{			
 			Vector3 pos = light->getParentSceneNode()->getPosition();
 			Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_PHOTONMAP) - pos;
@@ -125,4 +129,7 @@
 			photonMapCamera->setFOVy(2*alfa);
 			photonMapCamera->setDirection( dir );
+
+			photonMapCamera->setNearClipDistance(std::max(0.01f, d - r));
+			photonMapCamera->setFarClipDistance(r + d);	
 		}
 	}
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreCausticCubeMapRenderingRun.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreCausticCubeMapRenderingRun.cpp	(revision 949)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreCausticCubeMapRenderingRun.cpp	(revision 1055)
@@ -12,9 +12,11 @@
 														   String materialName,
 														   unsigned char photonMapTexId,
-														   bool updateAllFace)
+														   bool updateAllFace,
+														   float attenuation)
 		:CausticCubeMapRenderingRun(startFrame, updateInterval, resolution, updateAllFace)
 		, OgreRenderingRun(startFrame, updateInterval)
 		, RenderingRun(startFrame, updateInterval)
 {
+	this->attenuation = attenuation;
 	this->sharedRuns = sharedRuns;
 	this->name = name;
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp	(revision 874)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp	(revision 1055)
@@ -1,3 +1,4 @@
 #include "OgreDepthShadowMapRenderingRun.h"
+#include "OgreIlluminationManager.h"
 
 
@@ -15,5 +16,6 @@
 	this->light = light;
 	this->sharedRuns = sharedRuns;
-	this->name = name;	
+	names[0] = name + "1";	
+	names[1] = name + "2";	
 	this->materialName = materialName;
 
@@ -23,21 +25,24 @@
 void OgreDepthShadowMapRenderingRun::createDepthMap()
 {
-	TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name, 
-																		"default",
-																		TEX_TYPE_2D,
-																		resolutionX,
-																		resolutionY,
-																		0,
-																		0,
-																		PF_FLOAT16_RGBA,
-																		TU_RENDERTARGET);
-	 depthMapTexture = texPtr.getPointer();
-	 depthMapCamera = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA");
-	 //add viewport to rendertarget
-	 HardwarePixelBuffer* hpb = (depthMapTexture->getBuffer()).getPointer();
-	 RenderTarget* rt = hpb->getRenderTarget();
-	 Viewport* v = rt->addViewport(depthMapCamera);
-	 v->setOverlaysEnabled(false);
-	 rt->setAutoUpdated(false);
+	for(int i = 0; i < 2; i++)
+	{
+		TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(names[i], 
+																			"default",
+																			TEX_TYPE_2D,
+																			resolutionX,
+																			resolutionY,
+																			0,
+																			0,
+																			PF_FLOAT16_RGBA,
+																			TU_RENDERTARGET);
+		depthMapTextures[i] = texPtr.getPointer();
+		depthMapCameras[i] = Root::getSingleton()._getCurrentSceneManager()->createCamera(names[i] + "_CAMERA");
+		//add viewport to rendertarget
+		HardwarePixelBuffer* hpb = (depthMapTextures[i]->getBuffer()).getPointer();
+		RenderTarget* rt = hpb->getRenderTarget();
+		Viewport* v = rt->addViewport(depthMapCameras[i]);
+		v->setOverlaysEnabled(false);
+		rt->setAutoUpdated(false);
+	}
 }
 
@@ -64,15 +69,22 @@
 void OgreDepthShadowMapRenderingRun::updateDepthMap()
 {
-	setMaterialForVisibles(materialName, depthMapCamera, true);
-	
-	RenderTarget* rt = depthMapTexture->getBuffer().getPointer()->getRenderTarget();
-	
-	SceneManager* sm = Root::getSingleton()._getCurrentSceneManager();
-	
-	rt->update();	
-
-	//rt->writeContentsToFile("shadowmap.dds");
-
+	setMaterialForVisibles(materialName, depthMapCameras[0], true);	
+	RenderTarget* rt = depthMapTextures[0]->getBuffer().getPointer()->getRenderTarget();	
+	rt->update();
+	//restoreMaterials();
+	//rt->writeContentsToFile("shadowmap1.dds");
+	
+	//setMaterialForVisibles(materialName, depthMapCameras[1], true);	
+	RenderTarget* rt2 = depthMapTextures[1]->getBuffer().getPointer()->getRenderTarget();
+	rt2->update();
 	restoreMaterials();
+	//rt2->writeContentsToFile("shadowmap2.dds");
+
+	
+}
+
+void setnear()
+{
+
 }
 
@@ -84,22 +96,95 @@
 		if(light->getType() == Light::LT_DIRECTIONAL)
 		{
-			Vector3 dir = light->getDirection();
-			depthMapCamera->setDirection( dir );
+			//Vector3 dir = light->getDirection();
+			Vector3 dir = Vector3(0,-1,-1);
+			Vector3 pos;
+			float size;
+			
+			Camera* viewcam = OgreIlluminationManager::getSingleton().getMainCamera();
+			
+			//Matrix4 camView = viewcam->getViewMatrix();
+			//Matrix4 camViewI = camView.inverse();
+			//const AxisAlignedBox bt = viewcam->getWorldBoundingBox(true);
+			//AxisAlignedBox b = bt;
+			//b.transform(camView);
+			//SceneManager* sm = Root::getSingleton()._getCurrentSceneManager();
+			//SceneNode* node = sm->getRootSceneNode();
+			//const AxisAlignedBox bs(-35,-5 ,-75, 35, 15, 75);// = node->_getWorldAABB();
+			//AxisAlignedBox intersection = b.intersection(bs);
+			//pos = intersection.getCenter();			
+			//size = (intersection.getMaximum() - pos).length();
+			
 			//TODO: where to put light
-			depthMapCamera->setPosition( - dir * 100000 );
-			depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC);		
+			size = 30;
+			pos = Vector3(0,0,0);
+			
+			depthMapCameras[0]->setDirection( dir );
+			pos = pos - size * dir;			
+			depthMapCameras[0]->setPosition( pos );
+			depthMapCameras[0]->setProjectionType(PT_ORTHOGRAPHIC);		
+			Matrix4 fproj;
+			fproj = depthMapCameras[0]->getProjectionMatrix();
+			fproj = Matrix4::IDENTITY;
+			fproj.setScale(Vector3(1.0/20, 1.0/25, -1.0/100));
+			//fproj.setTrans(Vector3(0,0,-50));
+			depthMapCameras[0]->setCustomProjectionMatrix(true,fproj);
+
+
+			//camera2
+			dir.normalise();
+			size = abs(dir.crossProduct(Vector3(0,0,1)).length() * 2);
+			Vector3 viewDir = viewcam->getDirection();
+			float y = viewDir.y;
+			viewDir.y = std::min(0.0f, y);
+			viewDir.normalise();
+			Vector3 down(0,-1,0);
+			float cosA = viewDir.dotProduct(down);
+			Vector3 newDir = viewDir + down * 0.4; 
+			newDir.normalise();
+			pos = viewcam->getPosition();
+			size *= pos.y * 0.5 + 1;
+			pos += newDir * viewcam->getPosition().y 
+											/ newDir.dotProduct(down);
+			//pos.y = 0;
+			
+			
+			
+			depthMapCameras[1]->setDirection( dir );
+			pos = pos - 30 * dir;			
+			depthMapCameras[1]->setPosition( pos );
+			depthMapCameras[1]->setProjectionType(PT_ORTHOGRAPHIC);		
+			Matrix4 fproj2;
+			fproj2 = depthMapCameras[1]->getProjectionMatrix();
+			fproj2 = Matrix4::IDENTITY;
+			fproj2.setScale(Vector3(1.0/size, 1.0/size, -1.0/100));
+			//fproj.setTrans(Vector3(0,0,-50));
+			depthMapCameras[1]->setCustomProjectionMatrix(true,fproj2);
+			
+			
+/*LISPSM
+			Vector3 viewdir = viewcam->getDirection();
+			Vector3 lightdir = dir;
+
+			float dotProd = viewdir.dotProduct(lightdir);
+			float sinGamma;
+			sinGamma = sqrt(1.0-dotProd*dotProd);
+			g_fsinGamma = sinGamma;
+
+			Vector3 newVdir = viewdir;
+			Matrix4 proj;*/
+
 		}
 		else if(light->getType() == Light::LT_SPOTLIGHT)
 		{
-			Vector3 dir = light->getDirection();
+	/*		Vector3 dir = light->getDirection();
 			depthMapCamera->setDirection( dir );
 			Vector3 pos = light->getParentNode()->getWorldPosition();
 			depthMapCamera->setPosition(pos);
 			depthMapCamera->setProjectionType(PT_PERSPECTIVE);		
-			depthMapCamera->setFOVy(light->getSpotlightOuterAngle());
+			depthMapCamera->setFOVy(light->getSpotlightOuterAngle());*/
 		}
 		else//point light
 		{
-			Vector3 pos = light->getParentNode()->getWorldPosition();
+	/*		Vector3 pos = light->getParentNode()->getWorldPosition();
 			Vector3 dir = -pos;
 			depthMapCamera->setDirection( dir );
@@ -111,5 +196,5 @@
 	
 			//OGRE_EXCEPT(0, "NOT implemented for Pointlight", "OgreDepthShadowMapRenderingRun::refreshLight");
-			
+		*/	
 			/*Vector3 pos = light->getParentNode()->getWorldPosition();
 			Vector3 dir = -pos;
@@ -123,12 +208,12 @@
 }
 
-Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix()
-{
-	return depthMapCamera->getViewMatrix();
-}
-
-Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix()
-{
-	return depthMapCamera->getProjectionMatrix() * depthMapCamera->getViewMatrix();
-}
-
+Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix(int i)
+{
+	return depthMapCameras[i]->getViewMatrix();
+}
+
+Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix(int i)
+{
+	return depthMapCameras[i]->getProjectionMatrix() * depthMapCameras[i]->getViewMatrix();
+}
+
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreReducedCubeMapRenderingRun.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreReducedCubeMapRenderingRun.cpp	(revision 790)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreReducedCubeMapRenderingRun.cpp	(revision 1055)
@@ -27,5 +27,5 @@
 {
 	reducedCubemapTexture = createCubeRenderTexture(name, 
-												sharedRuns->getRootPosition(ILLUMRUN_REDUCED_CUBEMAP),
+												sharedRuns->getRootPosition(),
 												resolution,
 												PF_FLOAT16_RGBA);
@@ -42,7 +42,7 @@
 //	mat->getTechnique(0)->getPass(0)->setFragmentProgramParameters(fpParams); 
 	
+	renderFullscreenQuad("GameTools/CubeMap/Reduce", rt);
+	
 	//rt->writeContentsToFile("cubbereduce" + StringConverter::toString(facenum) + ".dds");
-
-	renderFullscreenQuad("GameTools/CubeMap/Reduce", rt);
 }
 
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreChildParticlesystemRenderingRun.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreChildParticlesystemRenderingRun.cpp	(revision 1055)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreChildParticlesystemRenderingRun.cpp	(revision 1055)
@@ -0,0 +1,115 @@
+#include "OgreChildPSystemRenderingRun.h"
+#include "OgreIlluminationManager.h"
+#include "OgreDistanceCubeMapRenderingRun.h"
+
+
+
+OgreChildPSystemRenderingRun::OgreChildPSystemRenderingRun(OgreSharedRuns* sharedRuns,
+															String name,
+															unsigned long startFrame,
+															unsigned long updateInterval,
+															unsigned int resolution,
+															bool perspectiveRendering,
+															String childParticleSystemName,
+															String particleScriptName,
+															bool useOwnMaterial,
+															String materialName)
+														   :ChildPsystemRenderingRun(resolution, perspectiveRendering, startFrame, updateInterval)
+														   , OgreRenderingRun(startFrame, updateInterval)
+														   , RenderingRun(startFrame, updateInterval)
+{
+	this->sharedRuns = sharedRuns;
+	this->name = name;	
+	this->resolution = resolution;
+	this->materialName = materialName;
+	this->particleScriptName = particleScriptName;
+	this->perspectiveRendering = perspectiveRendering;
+	this->childParticleSystemName = childParticleSystemName;
+	this->useOwnMaterial = useOwnMaterial;
+	createImpostorTexture();	
+}
+
+void OgreChildPSystemRenderingRun::createImpostorTexture()
+{
+	TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name, 
+																		"default",
+																		TEX_TYPE_2D,
+																		resolution,
+																		resolution,
+																		0,
+																		0,
+																		PF_FLOAT16_RGBA,
+																		TU_RENDERTARGET);
+	 impostorTexture = texPtr.getPointer();
+	 impostorCamera = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA");
+	 //add viewport to rendertarget
+	 HardwarePixelBuffer* hpb = (impostorTexture->getBuffer()).getPointer();
+	 RenderTarget* rt = hpb->getRenderTarget();
+	 Viewport* v = rt->addViewport(impostorCamera);
+	 v->setOverlaysEnabled(false);
+	 rt->setAutoUpdated(false);
+}
+
+void OgreChildPSystemRenderingRun::updateFrame(unsigned long frameNum)
+{
+	
+	Material* mat = (Material*) MaterialManager::getSingleton().getByName(materialName).getPointer();
+
+    SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
+	RenderQueue* rq = sm->getRenderQueue();
+	rq->clear();
+
+	Sphere boundSphere = ((OgreSharedRuns*)sharedRuns->getRoot(ILLUMRUN_HPP_IMPOSTOR))->getBoundingSphere();
+	Camera* mainCam = OgreIlluminationManager::getSingleton().getMainCamera();
+	impostorCamera->setPosition(mainCam->getPosition());
+	Vector3 dir = boundSphere.getCenter() - mainCam->getPosition();
+	float r = boundSphere.getRadius();
+	float d = dir.normalise();
+	impostorCamera->setDirection(dir);
+
+	if(perspectiveRendering)
+	{
+		impostorCamera->setProjectionType(PT_PERSPECTIVE);
+		impostorCamera->setAspectRatio(1.0);
+		Radian a = Math::ASin(r / d);
+		impostorCamera->setFOVy(a * 2.0);
+		impostorCamera->setNearClipDistance(std::max(0.01f, d - r));
+		impostorCamera->setFarClipDistance(r + d);		
+	}
+	else
+	{
+		impostorCamera->setPosition(boundSphere.getCenter());
+		impostorCamera->setProjectionType(PT_ORTHOGRAPHIC);
+		Matrix4 m;
+		m = Matrix4::IDENTITY;
+		float scale = 1.0 / boundSphere.getRadius();
+		m.setScale(Vector3(scale, scale, scale));
+		impostorCamera->setCustomProjectionMatrix(true, m);
+	}	
+
+	ParticleSystem* psys = Root::getSingleton()._getCurrentSceneManager()->getParticleSystem(childParticleSystemName);
+	psys->getParentSceneNode()->setPosition(boundSphere.getCenter());
+	psys->_notifyCurrentCamera(impostorCamera);
+	psys->_updateRenderQueue(rq);
+	
+	if(!useOwnMaterial)
+		setMaterialForRenderables(materialName,rq);
+	
+	RenderTarget* rt = impostorTexture->getBuffer().getPointer()->getRenderTarget();
+	 
+	rt->update();	
+	
+	/*
+		static int framecount = 0;
+		String filename = "photon";
+		filename.append(this->name);
+		//filename.append(StringConverter::toString(framecount));
+		filename.append(".png");
+		rt->writeContentsToFile(filename);
+		framecount++;
+	*/
+	
+	if(!useOwnMaterial)
+		restoreMaterials();
+}
+
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticCasterRenderTechnique.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticCasterRenderTechnique.cpp	(revision 949)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticCasterRenderTechnique.cpp	(revision 1055)
@@ -15,4 +15,5 @@
 																bool updateAllFace,
 																bool useDistance,
+																float attenuation,
 																Pass* pass,
 																OgreRenderable* parentRenderable,
@@ -22,4 +23,5 @@
 							RenderTechnique( parentRenderable, parentTechniqueGroup)
 {	
+	this->attenuation = attenuation;
 	this->photonMapMaterialName = photonMapMaterialName;
 	
@@ -103,5 +105,6 @@
 												causticMapMaterialName,
 												photonMapTexID,
-												updateAllFace
+												updateAllFace,
+												attenuation
 												);
 
@@ -185,4 +188,10 @@
 		OgreCausticCasterRenderTechniqueFactory* f = (OgreCausticCasterRenderTechniqueFactory*) factory;
 		f->causticMapMaterialName =  params;
+	}
+
+	void parseAttenuation(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreCausticCasterRenderTechniqueFactory* f = (OgreCausticCasterRenderTechniqueFactory*) factory;
+		f->attenuation =  StringConverter::parseReal(params);
 	}
 }
@@ -206,5 +215,6 @@
 	this->attributeParsers.insert(AttribParserList::value_type("distance_impostor", (ILLUM_ATTRIBUTE_PARSER) parseUseDistance));
 	this->attributeParsers.insert(AttribParserList::value_type("update_all_face", (ILLUM_ATTRIBUTE_PARSER) parseUpdateAllFace));
-
+	this->attributeParsers.insert(AttribParserList::value_type("attenuation", (ILLUM_ATTRIBUTE_PARSER) parseAttenuation));
+	
 }
 
@@ -216,4 +226,5 @@
 {	
 	//reset parameters
+	attenuation = 1.0;
 	startFrame = 1;
 	photonMapUpdateInterval = 1;
@@ -237,5 +248,6 @@
 												photonMapTexID,
 												updateAllFace,
-												useDistance,						
+												useDistance,
+												attenuation,
 												pass,
 												parentRenderable,
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowRecieverRenderTechnique.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowRecieverRenderTechnique.cpp	(revision 949)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowRecieverRenderTechnique.cpp	(revision 1055)
@@ -52,7 +52,9 @@
 		TextureUnitState* st = newpass->createTextureUnitState();		
 		st->setTextureFiltering(TFO_BILINEAR);		
+		st = newpass->createTextureUnitState();		
+		st->setTextureFiltering(TFO_BILINEAR);		
 
 		newpass->setSceneBlending(SBT_MODULATE);
-		newpass->setDepthBias(5);
+		newpass->setDepthBias(7);
 		techn->movePass(lastpass, index);			
 	}
@@ -93,10 +95,14 @@
 					
 			passes.at(i)->getTextureUnitState(0)->setTextureName(
-				depthRun->getDepthMapTextureName());
+				depthRun->getDepthMapTextureName(0));
+			passes.at(i)->getTextureUnitState(1)->setTextureName(
+				depthRun->getDepthMapTextureName(1));
 
 			//TODO: set matrices
 			GpuProgramParametersSharedPtr fpParams = passes.at(i)->getFragmentProgramParameters();
-			fpParams->setNamedConstant("lightView", depthRun->getLightViewMatrix()); 
-			fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix()); 
+			fpParams->setNamedConstant("lightView", depthRun->getLightViewMatrix(0)); 
+			fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix(0)); 
+			fpParams->setNamedConstant("lightView2", depthRun->getLightViewMatrix(1)); 
+			fpParams->setNamedConstant("lightViewProj2", depthRun->getLightViewProjMatrix(1)); 
 			
 			passes.at(i)->setActive(true);
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticRecieverRenderTechnique.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticRecieverRenderTechnique.cpp	(revision 949)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticRecieverRenderTechnique.cpp	(revision 1055)
@@ -106,4 +106,5 @@
 			Fparams->setNamedConstant("cubeMapCameraPosition",
 				causticCasters.at(i)->getRootPosition(ILLUMRUN_CAUSTIC_CUBEMAP));
+			Fparams->setNamedConstant("attenuation", cauCubeRun->getAttenuation());
 			passes.at(i)->setActive(true);
 		}	
@@ -135,4 +136,5 @@
 		f->causticFragmentProgram =  params;
 	}
+	
 }
 OgreCausticRecieverRenderTechniqueFactory::OgreCausticRecieverRenderTechniqueFactory()
@@ -145,4 +147,5 @@
 	this->attributeParsers.insert(AttribParserList::value_type("vertex_program_name", (ILLUM_ATTRIBUTE_PARSER) parseVertexProgram));
 	this->attributeParsers.insert(AttribParserList::value_type("fragment_program_name", (ILLUM_ATTRIBUTE_PARSER) parseFragmentProgram));
+	
 }
 
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreFireRenderTechnique.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreFireRenderTechnique.cpp	(revision 1055)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreFireRenderTechnique.cpp	(revision 1055)
@@ -0,0 +1,193 @@
+#include "OgreFireRenderTechnique.h"
+#include "OgreTechniqueGroup.h"
+#include "OgreIlluminationManager.h"
+
+int FireRenderTarget::targetsize = 2;
+
+RenderTarget* colortexture;
+RenderTarget* heattexture;
+
+FireRenderTarget::FireRenderTarget()
+{
+	int width = OgreIlluminationManager::getSingleton().getMainViewport()->getActualWidth()
+				/ targetsize;
+	int height = OgreIlluminationManager::getSingleton().getMainViewport()->getActualHeight()
+				/ targetsize;
+	
+	renderTarget = Root::getSingleton().getRenderSystem()->
+		createMultiRenderTarget("ILLUM_FIRE_TEXTURE");
+	MultiRenderTarget* mrt = (MultiRenderTarget*) renderTarget;
+	{
+		TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual("ILLUM_FIRE_COLOR_TEXTURE", 
+																			"default",
+																			TEX_TYPE_2D,
+																			width,
+																			height,
+																			0,
+																			0,
+																			PF_FLOAT16_RGBA,
+																			TU_RENDERTARGET);
+		Texture* texture = texPtr.getPointer();
+		//add viewport to rendertarget
+		HardwarePixelBuffer* hpb = (texture->getBuffer()).getPointer();
+		RenderTarget* rt = hpb->getRenderTarget();
+		
+		colortexture = rt;
+		RenderTexture* colorTex = (RenderTexture*) rt;
+		mrt->bindSurface(0, colorTex);
+	}
+
+	{
+		TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual("ILLUM_FIRE_HEAT_TEXTURE", 
+																			"default",
+																			TEX_TYPE_2D,
+																			width,
+																			height,
+																			0,
+																			0,
+																			PF_FLOAT16_RGBA,
+																			TU_RENDERTARGET);
+		Texture* texture = texPtr.getPointer();
+		//add viewport to rendertarget
+		HardwarePixelBuffer* hpb = (texture->getBuffer()).getPointer();
+		RenderTarget* rt = hpb->getRenderTarget();
+		
+		heattexture = rt;
+		RenderTexture* heatTex = (RenderTexture*) rt;
+		mrt->bindSurface(1, heatTex);
+
+		
+	}
+	Viewport* v = mrt->addViewport(OgreIlluminationManager::getSingleton().getMainCamera());
+	v->setOverlaysEnabled(false);
+	mrt->setAutoUpdated(false);	
+
+	SceneManager* sm = Root::getSingleton()._getCurrentSceneManager();
+	sm->getRenderQueue()->clear();
+	sm->setFindVisibleObjects(false);
+	mrt->update();
+	sm->setFindVisibleObjects(true);
+}
+
+OgreFireRenderTechnique::OgreFireRenderTechnique( unsigned char depthTexID,
+												Pass* pass,
+												OgreRenderable* parentRenderable,
+												OgreTechniqueGroup* parentTechniqueGroup)
+							:RenderTechnique( parentRenderable, parentTechniqueGroup),
+							OgreRenderTechnique(pass, parentRenderable, parentTechniqueGroup)							
+{
+	this->depthTexID = depthTexID;
+	OgreIlluminationManager::getSingleton().createGlobalRun(ILLUMRUN_SCENE_CAMERA_DEPTH);
+	
+	
+	OgreSceneCameraDepthRenderingRun* run = (OgreSceneCameraDepthRenderingRun*)
+		OgreIlluminationManager::getSingleton().getGlobalRun(ILLUMRUN_SCENE_CAMERA_DEPTH)->asOgreRenderingRun();
+	
+	pass->getTextureUnitState(depthTexID)->setTextureName(run->getDepthTextureName());
+	
+	if(OgreIlluminationManager::getSingleton().
+		getGlobalTarget(ILLUM_GLOBAL_TARGET_FIREPARTICLES) == 0)
+	{
+		FireRenderTarget* frt = new FireRenderTarget();
+		OgreIlluminationManager::getSingleton().
+			addGlobalTarget(ILLUM_GLOBAL_TARGET_FIREPARTICLES, frt);
+	}
+	
+	FireRenderTarget* frt = (FireRenderTarget*) OgreIlluminationManager::getSingleton().
+			getGlobalTarget(ILLUM_GLOBAL_TARGET_FIREPARTICLES);
+	frt->renderTarget->addListener(this);
+	OgreIlluminationManager::getSingleton().addUpdateListener(this);
+	Root::getSingleton().addFrameListener(this);
+}
+
+void  OgreFireRenderTechnique::preRenderTargetUpdate (const RenderTargetEvent &evt)
+{
+	parentOgreRenderable->setVisible(lastVisibility);
+}
+void  OgreFireRenderTechnique::postRenderTargetUpdate (const RenderTargetEvent &evt)
+{
+	parentOgreRenderable->setVisible(false);
+}
+
+bool  OgreFireRenderTechnique::frameEnded (const FrameEvent &evt)
+{
+	parentOgreRenderable->setVisible(lastVisibility);
+
+	return true;
+}
+void OgreFireRenderTechnique::preAllUpdates()
+{
+	lastVisibility = parentOgreRenderable->isVisible();
+	parentOgreRenderable->setVisible(false);
+}
+
+
+OgreFireRenderTechnique::~OgreFireRenderTechnique()
+{
+
+}
+
+void OgreFireRenderTechnique::update(unsigned long frameNum)
+{
+	OgreIlluminationManager::getSingleton().updateGlobalRun(ILLUMRUN_SCENE_CAMERA_DEPTH, frameNum);	
+
+	///render the fire to a target
+	FireRenderTarget* frt = (FireRenderTarget*) OgreIlluminationManager::getSingleton().
+					getGlobalTarget(ILLUM_GLOBAL_TARGET_FIREPARTICLES);
+	
+	SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 
+	RenderQueue* rq = sm->getRenderQueue();
+	rq->clear();
+	rq->addRenderable(parentOgreRenderable->getRenderable());
+	sm->setFindVisibleObjects(false);
+	
+	frt->renderTarget->update();
+	
+	sm->setFindVisibleObjects(true);
+
+	//colortexture->writeContentsToFile("firecolor.tga");
+	//heattexture->writeContentsToFile("fireheat.tga");
+
+}
+
+namespace FireParsers
+{
+///Technique parsers
+	void parseDepthTexID(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreFireRenderTechniqueFactory* f = (OgreFireRenderTechniqueFactory*) factory;
+		f->depthTexID =  StringConverter::parseUnsignedInt(params);
+	}
+}
+
+OgreFireRenderTechniqueFactory::OgreFireRenderTechniqueFactory()
+{
+	typeName = "Fire";
+	
+	using namespace FireParsers;
+	
+	//register parsers
+	this->attributeParsers.insert(AttribParserList::value_type("texture_unit_id", (ILLUM_ATTRIBUTE_PARSER) parseDepthTexID));
+}
+
+OgreRenderTechnique* OgreFireRenderTechniqueFactory::createInstance( 
+										IllumTechniqueParams* params,
+										Pass* pass,
+										OgreRenderable* parentRenderable,
+										OgreTechniqueGroup* parentTechniqueGroup)
+{	
+	//reset parameters
+	depthTexID = 1;
+	
+	parseParams(params);
+
+	OgreFireRenderTechnique* result = new OgreFireRenderTechnique(
+												depthTexID,
+												pass,
+												parentRenderable,
+												parentTechniqueGroup);
+	return result;
+}
+
+
+
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreSBBRenderTechnique.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreSBBRenderTechnique.cpp	(revision 874)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreSBBRenderTechnique.cpp	(revision 1055)
@@ -13,12 +13,40 @@
 {
 	this->depthTexID = depthTexID;
-	OgreIlluminationManager::getSingleton().createGlobalRun(ILLUMRUN_SCENE_CAMERA_DEPTH);
 	
+	OgreIlluminationManager::getSingleton().createGlobalRun(ILLUMRUN_SCENE_CAMERA_DEPTH);	
 	
 	OgreSceneCameraDepthRenderingRun* run = (OgreSceneCameraDepthRenderingRun*)
 		OgreIlluminationManager::getSingleton().getGlobalRun(ILLUMRUN_SCENE_CAMERA_DEPTH)->asOgreRenderingRun();
+
+	Root::getSingleton().addFrameListener(this);
+	OgreIlluminationManager::getSingleton().getMainViewport()
+								->getTarget()->addListener(this);
+	OgreIlluminationManager::getSingleton().addUpdateListener(this);
 	
 	pass->getTextureUnitState(depthTexID)->setTextureName(run->getDepthTextureName());
 	
+}
+
+void OgreSBBRenderTechnique::preAllUpdates()
+{
+	lastVisibility = parentOgreRenderable->isVisible();
+	parentOgreRenderable->setVisible(false);
+}
+void  OgreSBBRenderTechnique::preRenderTargetUpdate (const RenderTargetEvent &evt)
+{
+	//parentOgreRenderable->setVisible(lastVisibility);	
+}
+void  OgreSBBRenderTechnique::postRenderTargetUpdate (const RenderTargetEvent &evt)
+{
+	//parentOgreRenderable->setVisible(false);
+}
+bool  OgreSBBRenderTechnique::frameEnded (const FrameEvent &evt)
+{
+	
+	return true;
+}
+void  OgreSBBRenderTechnique::postAllUpdates()
+{
+	parentOgreRenderable->setVisible(lastVisibility);	
 }
 
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreHierarchicalParticleSystemTechnique.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreHierarchicalParticleSystemTechnique.cpp	(revision 1055)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreHierarchicalParticleSystemTechnique.cpp	(revision 1055)
@@ -0,0 +1,179 @@
+#include "OgreCubeMapRenderTechnique.h"
+#include "OgreTechniqueGroup.h"
+#include "OgreHierarchicalParticleSystemTechnique.h"
+#include "OgreChildPSystemRenderingRun.h"
+
+OgreHierarchicalParticleSystemTechnique::OgreHierarchicalParticleSystemTechnique(
+														unsigned long startFrame,
+														unsigned long impostorUpdateInterval,
+														unsigned int impostorResolution,
+														unsigned char impostorTexID,
+														bool useDistCalc,
+														bool perspectiveRendering,
+														String childPSysScriptName,
+														bool useOwnMaterial,
+														String impostorMaterialName,
+														Pass* pass,
+														OgreRenderable* parentRenderable,
+														OgreTechniqueGroup* parentTechniqueGroup)
+							:OgreRenderTechnique( pass, parentRenderable, parentTechniqueGroup),
+							HierarchicalParticleSystemTechnique(startFrame, impostorUpdateInterval, impostorResolution, useDistCalc, perspectiveRendering, parentRenderable, parentTechniqueGroup),
+							RenderTechnique(parentRenderable, parentTechniqueGroup) 
+{	
+	this->impostorTexID = impostorTexID;
+	this->childPSysScriptName = childPSysScriptName;
+	this->impostorMaterialName = impostorMaterialName;
+														
+	
+	if(sharedRuns->getRun(ILLUMRUN_HPP_IMPOSTOR) == 0)
+		sharedRuns->addRun(ILLUMRUN_HPP_IMPOSTOR, createChildPSysRenderingRun());	
+
+	//create the Particle system
+	String name = parentOgreRenderable->getName() + "_small_PSYS";
+	ParticleSystem* psys = Root::getSingleton()._getCurrentSceneManager()->createParticleSystem(name, childPSysScriptName);
+	SceneNode* node = Root::getSingleton()._getCurrentSceneManager()->getRootSceneNode()->createChildSceneNode();
+	node->attachObject(psys);
+	psys->setVisible(false);
+}
+
+
+OgreHierarchicalParticleSystemTechnique::~OgreHierarchicalParticleSystemTechnique()
+{
+
+}
+
+RenderingRun* OgreHierarchicalParticleSystemTechnique::createChildPSysRenderingRun()
+{
+	return new OgreChildPSystemRenderingRun( (OgreSharedRuns*) parentTechniqueGroup->getSharedRuns(), 
+												parentOgreRenderable->getName()  + "_HPP_IMPOSTOR",
+												startFrame,
+												impostorUpdateInterval,
+												impostorResolution,
+												perspectiveRendering,
+												childPSysName,
+												childPSysScriptName,
+												useOwnMaterial,
+												impostorMaterialName);
+}
+
+///Technique Parsers
+namespace HPSParsers
+{
+	void parseStartFrame(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory;
+		f->startFrame =  StringConverter::parseUnsignedLong(params);
+	}
+	void parseImpostorUpdateInterval(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory;
+		f->impostorUpdateInterval =  StringConverter::parseUnsignedLong(params);
+	}
+
+	void parseImpostorResolution(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory;
+		f->impostorResolution =  StringConverter::parseUnsignedInt(params);
+	}
+
+	void parseImpostorTexID(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory;
+		f->impostorTexID =  StringConverter::parseUnsignedInt(params);
+	}
+
+	void parseUseDistCalc(String& params, RenderTechniqueFactory* factory)
+	{
+	/*	OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory;
+		// format: on/off tolerance(float)
+		StringVector vecparams = StringUtil::split(params, " \t");
+
+		if(StringConverter::parseBool(vecparams[0]))//on
+		{
+			f->useDistCalc = true;
+
+			if(vecparams.size()>1)
+			{			
+				f->distTolerance = StringConverter::parseReal(vecparams[1]);
+			}
+		}
+		else
+		{
+			f->useDistCalc = false;
+		}*/
+		///TODO
+	}
+
+	void parsePerspectiveRendering(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory;
+		f->perspectiveRendering = StringConverter::parseBool(params);
+	}
+	void parseMaterialName(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory;
+		f->impostorMaterialName = params;
+		f->useOwnMaterial = false;
+	}
+	void parseScriptName(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory;
+		f->childPSysScriptName = params;
+	}
+
+	
+}
+///Technique factory
+OgreHierarchicalParticleSystemTechniqueFactory::OgreHierarchicalParticleSystemTechniqueFactory()
+{
+	typeName = "HPS";
+
+	using namespace HPSParsers;
+
+	//register parsers
+	this->attributeParsers.insert(AttribParserList::value_type("start_frame", (ILLUM_ATTRIBUTE_PARSER) parseStartFrame));
+	this->attributeParsers.insert(AttribParserList::value_type("update_interval", (ILLUM_ATTRIBUTE_PARSER) parseImpostorUpdateInterval));
+	this->attributeParsers.insert(AttribParserList::value_type("resolution", (ILLUM_ATTRIBUTE_PARSER) parseImpostorResolution));
+	this->attributeParsers.insert(AttribParserList::value_type("texture_unit_id", (ILLUM_ATTRIBUTE_PARSER) parseImpostorTexID));
+	this->attributeParsers.insert(AttribParserList::value_type("distance_calc", (ILLUM_ATTRIBUTE_PARSER) parseUseDistCalc));
+	this->attributeParsers.insert(AttribParserList::value_type("perspective", (ILLUM_ATTRIBUTE_PARSER) parsePerspectiveRendering));
+	this->attributeParsers.insert(AttribParserList::value_type("particle_script", (ILLUM_ATTRIBUTE_PARSER) parseScriptName));
+	this->attributeParsers.insert(AttribParserList::value_type("material", (ILLUM_ATTRIBUTE_PARSER) parseMaterialName));
+	
+}
+
+OgreRenderTechnique* OgreHierarchicalParticleSystemTechniqueFactory::createInstance( 
+										IllumTechniqueParams* params,
+										Pass* pass,
+										OgreRenderable* parentRenderable,
+										OgreTechniqueGroup* parentTechniqueGroup)
+{	
+	impostorUpdateInterval = 1;
+	impostorResolution = 256;
+	startFrame = 1;	
+	useDistCalc = false;
+	impostorTexID = 0;
+	perspectiveRendering = true;
+	impostorMaterialName = "";
+	childPSysScriptName = "";
+	bool useOwnMaterial = true;
+
+	parseParams(params);
+
+	OgreHierarchicalParticleSystemTechnique* result = new OgreHierarchicalParticleSystemTechnique(
+												startFrame,
+												impostorUpdateInterval,
+												impostorResolution,
+												impostorTexID,
+												useDistCalc,
+												perspectiveRendering,
+												childPSysScriptName,
+												useOwnMaterial,
+												impostorMaterialName,
+												pass,
+												parentRenderable,
+												parentTechniqueGroup);
+	
+	return result;
+}
+
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreSharedRuns.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreSharedRuns.cpp	(revision 949)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreSharedRuns.cpp	(revision 1055)
@@ -1,4 +1,35 @@
 #include "..\include\OgreSharedRuns.h"
 #include "OgreIlluminationManager.h"
+
+void OgreSharedRuns::runChanged(RenderingRunType runType, RenderingRun* run)
+{
+	if(child1 != 0) child1->runChanged(runType, run);
+	if(child2 != 0) child2->runChanged(runType, run);
+	
+	std::vector<TechniqueGroup*>::iterator it = childTechniqueGroups.begin();
+	std::vector<TechniqueGroup*>::iterator itend = childTechniqueGroups.end();
+
+	while(it != itend)
+	{
+		(*it)->runChanged(runType, run);
+		it++;
+	}
+}
+
+void OgreSharedRuns::runUpdated(RenderingRunType runType, RenderingRun* run)
+{
+	if(child1 != 0) child1->runUpdated(runType, run);
+	if(child2 != 0) child2->runUpdated(runType, run);
+	
+
+	std::vector<TechniqueGroup*>::iterator it = childTechniqueGroups.begin();
+	std::vector<TechniqueGroup*>::iterator itend = childTechniqueGroups.end();
+
+	while(it != itend)
+	{
+		(*it)->runUpdated(runType, run);
+		it++;
+	}
+}
 
 RenderingRun* OgreSharedRuns::getRun(RenderingRunType runType)
@@ -108,5 +139,4 @@
 	{
 		runChanged( (*it).first, (*it).second );
-		runChanged( (*it).first, (*it).second );
 		it++;
 	}
@@ -135,5 +165,5 @@
 }
 
-bool OgreSharedRuns::haveCommonRuns(SharedRuns* r1, SharedRuns* r2)
+bool OgreSharedRuns::haveCommonRuns(SharedRuns* r1, SharedRuns* r2, std::vector<RenderingRunType>& commonruns)
 {
 	OgreSharedRuns* run1 = (OgreSharedRuns*) r1;
@@ -143,22 +173,40 @@
 	std::map<RenderingRunType, RenderingRun*>::iterator itend = run1->sharedRuns.end();
 
+	bool returnvalue = false;
 	while(it != itend)
 	{
 		if( run2->hasOwnRun((*it).first))
-			return true;
-		it++;
-	}
-
-	return false;
+		{
+			if(			 run1->getRun((*it).first)->asOgreRenderingRun()->
+				canJoin( run2->getRun((*it).first)->asOgreRenderingRun() )
+			   )
+			{
+				returnvalue = true;
+				commonruns.push_back((*it).first);
+			}
+		}
+		it++;
+	}
+
+	return returnvalue;
 }
 
 bool OgreSharedRuns::canJoin(SharedRuns* r1, SharedRuns* r2)
 {
+	std::vector<RenderingRunType> commonruns;
 	//check if they have common resources
-	if(!haveCommonRuns(r1, r2))
+	if(!haveCommonRuns(r1, r2, commonruns))
 		return false;
-
+	
+	float MAXRAD = 0xffffffff;
 	//check bounds
-	float MAXRAD = OgreIlluminationManager::getSingleton().getMaxJoinRadius();
+	for(int i = 0; i < commonruns.size(); i++)
+	{
+	 
+	 RenderingRunType type = commonruns.at(i);
+	 float marad = OgreIlluminationManager::getSingleton().getMaxJoinRadius(type);
+	 
+	 MAXRAD = std::min(MAXRAD, marad);
+	}
 
 	Sphere bSphere1 = ((OgreSharedRuns*) r1)->getBoundingSphere();
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp	(revision 949)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp	(revision 1055)
@@ -79,4 +79,9 @@
 	visitor = new VisibleFinderVisitor(&visibleObjects);
 	maxRad = 400;
+	
+	for(int i = 0; i < RUN_TYPE_COUNT; i++)
+	{
+		maxRads[(RenderingRunType)i] = (float) maxRad;
+	}
 
 	//register rendertechnique factories
@@ -95,4 +100,6 @@
 	OgreSBBRenderTechniqueFactory* sbb = new OgreSBBRenderTechniqueFactory();
 		addRenderTechniqueFactory(sbb);
+	OgreFireRenderTechniqueFactory* fire = new OgreFireRenderTechniqueFactory();
+		addRenderTechniqueFactory(fire);
 }
 
@@ -160,4 +167,7 @@
 void OgreIlluminationManager::initTechniques(Entity* e)
 {
+	if( e->getParentSceneNode() == 0 )//Entity not attached
+		return;
+
 	OgreSharedRuns* sharedruns = 0;
 	
@@ -215,4 +225,59 @@
 }
 
+
+void OgreIlluminationManager::initTechniques(BillboardSet* bbs, ParticleSystem* sys)
+{
+	if( bbs->getParentSceneNode() == 0 )//billboardset not attached
+		return;
+
+	OgreSharedRuns* sharedruns = 0;	
+
+	Material* mat = bbs->getMaterial().getPointer();
+	
+	OgreRenderable* rend = 0;	
+	OgreTechniqueGroup* group = 0;
+
+	for(unsigned int t = 0 ; t < mat->getNumTechniques() ; t++)
+	{
+		Technique* tech = mat->getTechnique(t);
+
+		for(unsigned int p = 0; p< tech->getNumPasses(); p++)
+		{
+			Pass* pass = tech->getPass(p);
+
+			std::vector<IllumTechniqueParams*>& techniques = pass->getIllumTechniques();
+			std::vector<IllumTechniqueParams*>::iterator i = techniques.begin(); 
+			std::vector<IllumTechniqueParams*>::iterator iend = techniques.end();
+			
+			while( i != iend)
+			{
+				IllumTechniqueParams* params = *i;
+				
+				if(rend == 0)
+				{
+					rend = new OgreRenderable(bbs, sys);
+					group = new OgreTechniqueGroup();
+					bbs->setRenderTechniqueGroup(group);							
+					
+					if( sharedruns == 0)
+					{									
+						sharedruns  = new OgreSharedRuns();
+						addSharedRuns(sharedruns);
+					}
+
+					group->addSharedRun(sharedruns);
+					sharedruns->addRenderable(rend);
+					sharedruns->updateBounds();
+				}
+				
+				createTechnique(params, pass, rend, sharedruns); 
+
+				i++;
+			}
+		}
+	}
+			
+}
+
 void OgreIlluminationManager::initTechniques()
 {
@@ -225,58 +290,5 @@
 			MovableObject* o = it.getNext();
 			Entity* e = (Entity*) o;
-
-		/*	OgreSharedRuns* sharedruns = 0;
-			
-			for(unsigned int s = 0; s < e->getNumSubEntities(); s++)
-			{
-				SubEntity* sube = e->getSubEntity(s);
-
-				Material* mat = sube->getMaterial().getPointer();
-				
-				OgreRenderable* rend = 0;	
-				OgreTechniqueGroup* group = 0;
-			
-				for(unsigned int t = 0 ; t < mat->getNumTechniques() ; t++)
-				{
-					Technique* tech = mat->getTechnique(t);
-
-					for(unsigned int p = 0; p< tech->getNumPasses(); p++)
-					{
-						Pass* pass = tech->getPass(p);
-
-						std::vector<IllumTechniqueParams*>& techniques = pass->getIllumTechniques();
-						std::vector<IllumTechniqueParams*>::iterator i = techniques.begin(); 
-						std::vector<IllumTechniqueParams*>::iterator iend = techniques.end();
-						
-						while( i != iend)
-						{
-							IllumTechniqueParams* params = *i;
-							
-							if(rend == 0)
-							{
-								rend = new OgreRenderable(e, s);
-								group = new OgreTechniqueGroup();
-								sube->setRenderTechniqueGroup(group);							
-								
-								if( sharedruns == 0)
-								{									
-									sharedruns  = new OgreSharedRuns();
-									addSharedRuns(sharedruns);
-								}
-
-								group->addSharedRun(sharedruns);
-								sharedruns->addRenderable(rend);
-								sharedruns->updateBounds();
-							}
-							
-							createTechnique(params, pass, rend, sharedruns); 
-
-							i++;
-						}
-					}
-				}
-			}
-
-		*/
+		
 			initTechniques(e);
 		}
@@ -290,56 +302,15 @@
 			MovableObject* o = it.getNext();
 			ParticleSystem* psys = (ParticleSystem*) o;
-
-			BillboardSet* bbset = findRenderableInParticleSystem(psys);
-			
-			OgreTechniqueGroup* group = 0;			
-			OgreSharedRuns* sharedruns = 0;
-			OgreRenderable* rend = 0;	
-						
-			String matName = psys->getMaterialName();
-			Material* mat = (Material*) MaterialManager::getSingleton().getByName(matName).getPointer();
-
-			for(unsigned int t = 0 ; t < mat->getNumTechniques() ; t++)
+			
+			try
 			{
-				Technique* tech = mat->getTechnique(t);
-
-				for(unsigned int p = 0; p< tech->getNumPasses(); p++)
-				{
-					Pass* pass = tech->getPass(p);
-
-					std::vector<IllumTechniqueParams*>& techniques = pass->getIllumTechniques();
-					std::vector<IllumTechniqueParams*>::iterator i = techniques.begin(); 
-					std::vector<IllumTechniqueParams*>::iterator iend = techniques.end();
-
-					
-					while( i != iend)
-					{
-						IllumTechniqueParams* params = *i;
-						
-						if(rend == 0)
-						{
-							rend = new OgreRenderable(bbset);
-							group = new OgreTechniqueGroup();
-							bbset->setRenderTechniqueGroup(group);							
-							
-							if( sharedruns == 0)
-							{									
-								sharedruns  = new OgreSharedRuns();
-								addSharedRuns(sharedruns);
-							}
-
-							group->addSharedRun(sharedruns);
-							sharedruns->addRenderable(rend);
-							sharedruns->updateBounds();
-						}
-
-						createTechnique(params, pass, rend, sharedruns); 
-
-						i++;
-					}
-				}
+			 BillboardSet* bbset = findRenderableInParticleSystem(psys);
+			 bbset->setMaterialName(psys->getMaterialName());
+			 initTechniques(bbset, psys);
 			}
-			
-
+			catch( ... )
+			{
+				//unsupported particle renderer, skip init
+			}
 		}
 	}
@@ -371,4 +342,29 @@
 		}
 
+		it++;
+	}
+}
+void OgreIlluminationManager::preAllUpdates()
+{
+	std::vector<UpdateListener*>::iterator it = updateListeners.begin();
+	std::vector<UpdateListener*>::iterator itend = updateListeners.end();
+
+	while(it != itend)
+	{
+		UpdateListener* l = *it;
+		l->preAllUpdates();
+		it++;
+	}
+}
+
+void OgreIlluminationManager::postAllUpdates()
+{
+	std::vector<UpdateListener*>::iterator it = updateListeners.begin();
+	std::vector<UpdateListener*>::iterator itend = updateListeners.end();
+
+	while(it != itend)
+	{
+		UpdateListener* l = *it;
+		l->postAllUpdates();
 		it++;
 	}
@@ -406,4 +402,6 @@
 		std::vector<const Renderable*>::iterator iter = visibleObjects.begin();
 		const std::vector<const Renderable*>::iterator iend = visibleObjects.end();
+
+		preAllUpdates();
 
 		while(iter != iend)
@@ -418,4 +416,6 @@
 		}
 
+		postAllUpdates();
+
 	}
 }
@@ -448,5 +448,5 @@
 		while(it2 != itend)
 		{
-			if( *it1 != *it2 && OgreSharedRuns::canJoin(*it1, *it2))
+			if( it1 != it2 && OgreSharedRuns::canJoin(*it1, *it2))
 			{
 				SharedRuns* newruns = (*it1)->joinRuns(*it2);
@@ -513,7 +513,24 @@
 }
 
+
+
 RenderingRun* OgreIlluminationManager::getGlobalRun(RenderingRunType runType)
 {
 	return globalSharedRuns.getRun(runType);
+}
+
+GlobalUseRenderTarget* OgreIlluminationManager::getGlobalTarget(GlobalTargetType type)
+{
+	std::map<GlobalTargetType, GlobalUseRenderTarget*>::iterator it = globalTargets.find(type);
+	
+	if( it != globalTargets.end())
+		return (*it).second;
+
+	return 0;
+}
+
+void OgreIlluminationManager::addGlobalTarget(GlobalTargetType type, GlobalUseRenderTarget* target)
+{
+	globalTargets[type] = target;  
 }
 
@@ -545,6 +562,6 @@
 				lightName + "DEPTH_SHADOW_MAP",
 				sm->getLight(lightName),
-				2048, //TODO
-				2048, //TODO
+				512, //TODO
+				512, //TODO
 				"GameTools/ShadowMapDepth" //TODO
 				);
Index: /GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/SharedRuns.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/SharedRuns.h	(revision 780)
+++ /GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/SharedRuns.h	(revision 1055)
@@ -4,4 +4,6 @@
 class TechniqueGroup;
 
+
+#define RUN_TYPE_COUNT 7
 /**
 	@brief Enum of RenderingRun types.
@@ -18,5 +20,6 @@
 	ILLUMRUN_PHOTONMAP,
 	ILLUMRUN_DEPTH_SHADOWMAP,
-	ILLUMRUN_SCENE_CAMERA_DEPTH
+	ILLUMRUN_SCENE_CAMERA_DEPTH,
+	ILLUMRUN_HPP_IMPOSTOR
 };
 
@@ -87,9 +90,9 @@
 	virtual void runUpdated(RenderingRunType runType, RenderingRun* run);
 	/**
-		@brief Sets child TechniqueGroup.
+		@brief Adds a child TechniqueGroup.
 		
 		@param group pointer to the TechniqueGroup instance to add.
 	*/	
-	void setTechniqueGroup(TechniqueGroup* group){childTechniques = group;}
+	virtual void addTechniqueGroup(TechniqueGroup* group) = 0;
 	/**
 		@brief Shows or hides this SharedRuns (and also all childnodes).
@@ -160,12 +163,5 @@
 	*/
 	SharedRuns* child2;
-	/**
-		@brief child TechniqueGroup instance.
-
-		If this SharedRuns node is a leaf, it containes a reference to a TechniqueGroup instance.
-		All messages will be transfered to this object, 
-		and bounding information will be retrieved from this TechniqueGroup
-	*/
-	TechniqueGroup* childTechniques;
+	
 	/**
 		@brief Collects RenderingRuns references from the child nodes, used when joining
Index: /GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderingRuns/ChildPSystemRenderingRun.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderingRuns/ChildPSystemRenderingRun.h	(revision 1055)
+++ /GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderingRuns/ChildPSystemRenderingRun.h	(revision 1055)
@@ -0,0 +1,43 @@
+#pragma once
+#include "RenderingRun.h"
+
+/**
+	@brief Base abstract class that defines a rendering process of a photon hit map.
+
+	A photon hit map stores the directions where the incoming photons are refracted by a caustic emitter object.
+	One pixel of the photon map represents one photon hit, hte direction is encoded in the RGB channels.
+	If  the alpha channel has zero value, the hit is invalid.
+*/
+class ChildPsystemRenderingRun : virtual public RenderingRun
+{	
+public:
+	/**
+		@brief Constructor.
+
+		@param startFrame				adds an offset to the current frame number to help evenly distribute updates between frames
+		@param updateInterval			update frequency
+	*/
+	ChildPsystemRenderingRun(
+							unsigned int resolution,
+							bool perspectiveRendering,
+							unsigned long startFrame,
+							unsigned long updateInterval)
+							:RenderingRun(startFrame, updateInterval)
+	{
+		this->resolution = resolution;
+		this->perspectiveRendering = perspectiveRendering;
+	}
+
+protected:
+	/**
+		@brief the resolution of the photonmap texture that was created by this run
+	*/
+	unsigned int resolution;
+	bool perspectiveRendering;
+    //inherited
+	virtual void updateFrame(unsigned long frameNum) = 0;	
+	/**
+		@brief Creates a photon hit map.
+	*/
+	virtual inline void createImpostorTexture() = 0;	
+};
Index: /GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderTechniques/HierarchicalParticleSystemTechnique.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderTechniques/HierarchicalParticleSystemTechnique.h	(revision 1055)
+++ /GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderTechniques/HierarchicalParticleSystemTechnique.h	(revision 1055)
@@ -0,0 +1,41 @@
+#pragma once
+#include "RenderTechnique.h"
+
+/**
+	@brief Base abstract class of rendering a particle system with the spherical billboard method. 	
+*/
+class HierarchicalParticleSystemTechnique : virtual public RenderTechnique
+{
+public:
+	/**
+		@brief Constructor.
+
+		@param parentRenderable the object to operate on
+		@param parentTechniqueGroup the TechniqueGroup this RenderedTechnique is attached to
+	*/
+	HierarchicalParticleSystemTechnique(
+							unsigned long startFrame,
+							unsigned long impostorUpdateInterval,
+							unsigned int impostorResolution,
+							bool useDistCalc,
+							bool perspectiveRendering,
+							ElementaryRenderable* parentRenderable,
+							TechniqueGroup* parentTechniqueGroup
+							);
+	~HierarchicalParticleSystemTechnique();
+
+	void update(unsigned long frameNum);
+
+protected:
+	unsigned long impostorUpdateInterval;
+	unsigned int impostorResolution;
+	/**
+			@brief offset in frame number used during update
+	*/
+	unsigned long startFrame;	
+	bool useDistCalc;
+	bool perspectiveRendering;
+
+	virtual RenderingRun* createChildPSysRenderingRun()=0;
+	
+};
Index: /GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/TechniqueGroup.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/TechniqueGroup.h	(revision 780)
+++ /GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/TechniqueGroup.h	(revision 1055)
@@ -26,5 +26,5 @@
 	*/
 	void addSharedRun(SharedRuns* sharedRuns){parentSharedRuns = sharedRuns;
-												parentSharedRuns->setTechniqueGroup(this);}
+												parentSharedRuns->addTechniqueGroup(this);}
 	/**
 		@brief Retrieves the shared runs.
Index: /GTP/trunk/Lib/Illum/IllumModule/IllumModule/scripts/illummodule.vcproj
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/IllumModule/scripts/illummodule.vcproj	(revision 780)
+++ /GTP/trunk/Lib/Illum/IllumModule/IllumModule/scripts/illummodule.vcproj	(revision 1055)
@@ -155,4 +155,7 @@
 				</File>
 				<File
+					RelativePath="..\src\RenderTechniques\HierarchicalParticleSystemTechnique.cpp">
+				</File>
+				<File
 					RelativePath="..\src\RenderTechniques\SBBRenderTechnique.cpp">
 				</File>
@@ -163,4 +166,7 @@
 				<File
 					RelativePath="..\src\RenderingRuns\CausticCubeMapRenderingRun.cpp">
+				</File>
+				<File
+					RelativePath="..\src\RenderingRuns\ChildPSystemRenderingRun.cpp">
 				</File>
 				<File
@@ -227,4 +233,7 @@
 				</File>
 				<File
+					RelativePath="..\include\RenderTechniques\HierarchicalParticleSystemTechnique.h">
+				</File>
+				<File
 					RelativePath="..\include\RenderTechniques\SBBRenderTechnique.h">
 				</File>
@@ -235,4 +244,7 @@
 				<File
 					RelativePath="..\include\RenderingRuns\CausticCubeMapRenderingRun.h">
+				</File>
+				<File
+					RelativePath="..\include\RenderingRuns\ChildPSystemRenderingRun.h">
 				</File>
 				<File
@@ -258,4 +270,10 @@
 				Name="Resource Files"
 				Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+				<File
+					RelativePath="..\..\..\..\..\..\..\EGDemoGame\Media\materials\scripts\car.material">
+				</File>
+				<File
+					RelativePath="..\..\..\..\..\..\..\EGDemoGame\Media\materials\programs\CarReflections.hlsl">
+				</File>
 			</Filter>
 		</Filter>
Index: /GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/SharedRuns.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/SharedRuns.cpp	(revision 780)
+++ /GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/SharedRuns.cpp	(revision 1055)
@@ -8,5 +8,5 @@
 	parent = 0;
 
-	childTechniques = 0;
+//	childTechniques = 0;
 }
 
@@ -49,5 +49,5 @@
 	if(child1 != 0) child1->runChanged(runType, run);
 	if(child2 != 0) child2->runChanged(runType, run);
-	if(childTechniques != 0) childTechniques->runChanged(runType, run);
+	//if(childTechniques != 0) childTechniques->runChanged(runType, run);
 }
 
@@ -56,5 +56,5 @@
 	if(child1 != 0) child1->runUpdated(runType, run);
 	if(child2 != 0) child2->runUpdated(runType, run);
-	if(childTechniques != 0) childTechniques->runUpdated(runType, run);
+	//if(childTechniques != 0) childTechniques->runUpdated(runType, run);
 }
 
Index: /GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderingRuns/ChildPSystemRenderingRun.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderingRuns/ChildPSystemRenderingRun.cpp	(revision 1055)
+++ /GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderingRuns/ChildPSystemRenderingRun.cpp	(revision 1055)
@@ -0,0 +1,3 @@
+#include "ChildPsystemRenderingRun.h"
+
+
Index: /GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderTechniques/HierarchicalParticleSystemTechnique.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderTechniques/HierarchicalParticleSystemTechnique.cpp	(revision 1055)
+++ /GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderTechniques/HierarchicalParticleSystemTechnique.cpp	(revision 1055)
@@ -0,0 +1,31 @@
+#include "HierarchicalParticleSystemTechnique.h"
+
+
+HierarchicalParticleSystemTechnique::HierarchicalParticleSystemTechnique(
+												unsigned long startFrame,
+												unsigned long impostorUpdateInterval,
+												unsigned int impostorResolution,
+												bool useDistCalc,
+												bool perspectiveRendering,
+												ElementaryRenderable* parentRenderable,
+												TechniqueGroup* parentTechniqueGroup)
+							:RenderTechnique( parentRenderable, parentTechniqueGroup)
+{
+	this->startFrame = startFrame;
+	this->impostorUpdateInterval = impostorUpdateInterval;
+	this->impostorResolution = impostorResolution;
+	this->useDistCalc = useDistCalc;
+	this->perspectiveRendering = perspectiveRendering;
+}
+
+HierarchicalParticleSystemTechnique::~HierarchicalParticleSystemTechnique()
+{
+
+}
+
+void HierarchicalParticleSystemTechnique::update(unsigned long frameNum)
+{
+	sharedRuns->updateRun(ILLUMRUN_HPP_IMPOSTOR, frameNum);	
+}
+
+
