Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreSharedRuns.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreSharedRuns.h	(revision 1055)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreSharedRuns.h	(revision 1425)
@@ -141,5 +141,5 @@
 		@param pointer to the RenderQueue to add the Renderables to
 	*/
-	void addRenderablesToQueue(RenderQueue* rq);
+	void addRenderablesToQueue(RenderQueue* rq, bool checkVisible = true);
 	/**
 		@brief Calls notifyCamera() to all the Renderables connected to this node
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h	(revision 1130)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h	(revision 1425)
@@ -15,5 +15,6 @@
 #include "OgreFireRenderTechnique.h"
 #include "OgreHierarchicalParticleSystemTechnique.h"
-
+#include "OgreIllumVolumeRenderTechnique.h"
+#include "OgrePhaseTextureRenderingRun.h"
 
 
@@ -69,4 +70,5 @@
 	unsigned int focusingMapSize;
 	unsigned int shadowMapSize;
+	unsigned int phaseTextureSize;
 	std::map<RenderingRunType,float> maxRads;
 	/**
@@ -152,4 +154,5 @@
 	void setMaxJoinRadius(RenderingRunType type, float rad){maxRads[type] = rad;}
 	void setFocusingMapSize(unsigned int size){focusingMapSize = size;}
+	void setPhaseTextureSize(unsigned int size){phaseTextureSize = size;}
 	void setShadowMapSize(unsigned int size){shadowMapSize = size;}
 	/**
@@ -291,4 +294,6 @@
 	*/
 	void updatePerLightRun(String lightName, RenderingRunType runType, unsigned long frameNum);
+
+	void savePhaseTextureToFile(String filename);
 
 	bool frameStarted(const FrameEvent& evt)
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 1351)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h	(revision 1425)
@@ -117,5 +117,5 @@
 		@param rq pointer to the filled Renderqueue instance to set material for
 	*/
-	void setMaterialForRenderables(String& materialName, RenderQueue* rq);
+	void setMaterialForRenderables(String& materialName, RenderQueue* rq, bool solidsonly = false);
 	/**
 		@brief Sets the given material for each Renderable visible from a given camera.
@@ -132,5 +132,5 @@
 		@param shadowcastersonly flag to search for only shadow casters
 	*/
-	void setMaterialForVisibles(String& materialName, Camera* cam, bool shadowcastersonly = false);
+	void setMaterialForVisibles(String& materialName, Camera* cam, bool shadowcastersonly = false, bool solidsonly = false);
 	/**
 		@brief Restores previously stored materials.
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreLightVolumeRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreLightVolumeRenderingRun.h	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreLightVolumeRenderingRun.h	(revision 1425)
@@ -0,0 +1,107 @@
+#pragma once
+
+//disable inheritance warning caused by multiple inheritance
+#if _WIN32
+#if _MSC_VER
+#pragma warning(disable: 4250)
+#endif
+#endif
+
+#include "OgreRenderingRun.h"
+#include "LightVolumeRenderingRun.h"
+#include "OgreSharedRuns.h"
+
+
+/**
+	@brief ColorCubeMapRenderingRun used in an OGRE environment.
+*/
+class OgreLightVolumeRenderingRun : public OgreRenderingRun,
+									public LightVolumeRenderingRun
+{	
+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 resolution			color cubemap resolution
+		@param materialName			the name of the material should be used when rendering the choton hit map
+	*/	
+	OgreLightVolumeRenderingRun(OgreSharedRuns* sharedRuns,
+								String name,
+								unsigned long startFrame,
+								unsigned long updateInterval,
+								unsigned int resolution,
+								unsigned int textureDepth,
+								String materialName);
+	/**
+		@brief returns the name of the resulting photon hit map
+	*/
+	String getLightVolumeTextureName()
+	{
+		if(textureDepth == 1)
+			return name;
+		else
+			return lightVolumeTexture3D->getName();
+	}
+	/**
+		@brief Refreshes light camera matrices, called in each update.
+	*/
+	void refreshLight();
+
+	Matrix4 getLightViewProjectionMatrix()
+	{
+		Matrix4 m = lightVolumeCamera->getProjectionMatrixWithRSDepth() * lightVolumeCamera->getViewMatrix();
+		Vector4 unitX(1,0,0,1);
+		Vector4 unitY(0,1,0,1);
+		Vector4 unitZ(0,0,1,1);
+		Vector4 tX = m * unitX;
+		Vector4 tY = m * unitY;
+		Vector4 tZ = m * unitZ;
+		return  m;
+				
+	}
+	
+protected:	
+	/**
+		@brief the name of the material should be used when rendering the choton hit map
+	*/
+	String materialName;
+	/**
+		@brief pointer to the nearest light source from the caster object
+	*/
+	Light* light;
+	/**
+		@brief the created photon hit map texture
+	*/
+	Camera* lightVolumeCamera;
+	/**
+		@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* lightVolumeTexture;
+	/**
+		@brief a pointer to the photonmap texture that was created by this run
+	*/
+	Texture* lightVolumeTexture3D;
+	unsigned char* volumeBuffer;
+	float systemRadius;	
+
+	void createVolumeBuffer();
+	
+	//inherited
+	void updateFrame(unsigned long frameNum);	
+	//inherited
+	inline void createLightVolumeMap();
+
+};
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePhaseTextureRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePhaseTextureRenderingRun.h	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePhaseTextureRenderingRun.h	(revision 1425)
@@ -0,0 +1,62 @@
+#pragma once
+
+//disable inheritance warning caused by multiple inheritance
+#if _WIN32
+#if _MSC_VER
+#pragma warning(disable: 4250)
+#endif
+#endif
+
+#include "OgreRenderingRun.h"
+#include "PhaseTextureRenderingRun.h"
+#include "OgreSharedRuns.h"
+
+
+/**
+	@brief ColorCubeMapRenderingRun used in an OGRE environment.
+*/
+class OgrePhaseTextureRenderingRun : public OgreRenderingRun,
+									public PhaseTextureRenderingRun
+{	
+public:
+
+	/**
+		@brief Constructor.
+
+		@param sharedRuns			a pointer to the OgreSharedRuns this run belongs to
+		@param name					the name of the depth map texture to be created
+		@param light				the light source this depth shadow map belongs to
+		@param resolutionX			the resolution width of the depth shadow map
+		@param resolutionY			the resolution height of the depth shadow map
+		@param materialName			the name of the material to be used when rendering the depth shadow map
+	*/	
+	OgrePhaseTextureRenderingRun(		String name,
+										unsigned int resolutionX,
+										unsigned int resolutionY,
+										String materialName);
+
+	/**
+		@brief returns the depth shadow map texture created by this run
+	*/
+	String getPhaseTextureName(){return name;}
+	
+protected:	
+	/**
+		@brief the name of the material to be used when rendering the depth shadow map
+	*/
+	String materialName;
+	/**
+		@brief the name of the phase texture that was created by this run
+	*/
+	String name;
+	/**
+		@brief a pointer to the phase texture that was created by this run
+	*/
+	Texture* phaseTexture;
+	Camera* phaseCamera;
+	
+	//inherited
+	void updateFrame(unsigned long frameNum);
+	inline void createPhaseTexture();
+	
+};
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderable.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderable.h	(revision 1055)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderable.h	(revision 1425)
@@ -64,5 +64,11 @@
 		@see ElementaryRenderable::setRenderGroup()
 	*/	
-	void  setRenderGroup (unsigned char groupID);
+	void setRenderGroup(unsigned char groupID);
+	/**
+		@brief Updates the given renderqueue for the wrapped renderable
+
+		@param rq pointer to the renderqueue to be updated
+	*/	
+	void updateRenderQueue(RenderQueue* rq);
 	/** 
 		@brief Retrieves if the renderable is hided or shown.
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreHierarchicalParticleSystemTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreHierarchicalParticleSystemTechnique.h	(revision 1330)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreHierarchicalParticleSystemTechnique.h	(revision 1425)
@@ -41,7 +41,5 @@
 	~OgreHierarchicalParticleSystemTechnique();
 
-	//inherited
-	void update(unsigned long frameNum);
-	
+		
 protected:
 	
@@ -58,5 +56,7 @@
 	//inherited
 	RenderingRun* createChildPSysRenderingRun();
+	RenderingRun* createLightVolumeRenderingRun();
 	virtual void impostorChanged(RenderingRun* run);
+	virtual void impostorUpdated(RenderingRun* run);
 };
 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreIllumVolumeRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreIllumVolumeRenderTechnique.h	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreIllumVolumeRenderTechnique.h	(revision 1425)
@@ -0,0 +1,76 @@
+#pragma once
+
+//disable inheritance warning caused by multiple inheritance
+#if _WIN32
+#if _MSC_VER
+#pragma warning(disable: 4250)
+#endif
+#endif
+
+#include "OgreRenderTechnique.h"
+#include "IllumVolumeRenderTechnique.h"
+
+/**
+	@brief CausticCasterRenderTechnique used in an OGRE environment.
+*/
+class OgreIllumVolumeRenderTechnique : public OgreRenderTechnique,
+											public IllumVolumeRenderTechnique
+{
+public:
+
+	OgreIllumVolumeRenderTechnique(unsigned long startFrame,
+							unsigned long illumVolumeUpdateInterval,
+							unsigned int illumTextureResolution,
+							unsigned int textureDepth,
+							unsigned char illumTexID,
+							bool useDistCalc,
+							String materialName,
+							String lightMatrixGPUParamName,
+							bool useHierarchicalImpostor,
+							unsigned char impostorTexID,
+							Pass* pass,
+							OgreRenderable* parentRenderable,
+							OgreTechniqueGroup* parentTechniqueGroup
+							);
+	/**
+		@brief Destructor.
+	*/
+	~OgreIllumVolumeRenderTechnique();
+	
+protected:
+	
+	String materialName;
+	unsigned char illumTexID;
+	String lightMatrixGPUParamName;
+	unsigned char impostorTexID;
+	
+	//inherited
+	RenderingRun* createLightVolumeRenderingRun();
+	void lightVolumeChanged(RenderingRun* run);
+	void lightVolumeUpdated(RenderingRun* run);
+	void hierarchicalImpostorUpdated(RenderingRun* run);
+};
+
+class OgreIllumVolumeRenderTechniqueFactory : public RenderTechniqueFactory
+{
+public:
+	
+	OgreIllumVolumeRenderTechniqueFactory();
+
+	OgreRenderTechnique* createInstance(IllumTechniqueParams* params,
+										Pass* pass,
+										OgreRenderable* parentRenderable,
+										OgreTechniqueGroup* parentTechniqueGroup);
+
+
+	String materialName;
+	unsigned char illumTexID;
+	unsigned long startFrame;	
+	unsigned long illumVolumeUpdateInterval;
+	unsigned int illumTextureResolution;
+	unsigned int textureDepth;	
+	bool useDistCalc;
+	String lightMatrixGPUParamName;
+	unsigned char impostorTexID;
+	bool useHierarchicalImpostor;	
+};
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.vcproj
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.vcproj	(revision 1337)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.vcproj	(revision 1425)
@@ -165,4 +165,7 @@
 				</File>
 				<File
+					RelativePath="..\src\RenderTechniques\OgreIllumVolumeRenderTechnique.cpp">
+				</File>
+				<File
 					RelativePath="..\src\RenderTechniques\OgreSBBRenderTechnique.cpp">
 				</File>
@@ -188,4 +191,10 @@
 				<File
 					RelativePath="..\src\RenderingRuns\OgreFocusingMapRenderingRun.cpp">
+				</File>
+				<File
+					RelativePath="..\src\RenderingRuns\OgreLightVolumeRenderingRun.cpp">
+				</File>
+				<File
+					RelativePath="..\src\RenderingRuns\OgrePhaseTextureRenderingRun.cpp">
 				</File>
 				<File
@@ -253,4 +262,7 @@
 				</File>
 				<File
+					RelativePath="..\include\RenderTechniques\OgreIllumVolumeRenderTechnique.h">
+				</File>
+				<File
 					RelativePath="..\include\RenderTechniques\OgreSBBRenderTechnique.h">
 				</File>
@@ -276,4 +288,10 @@
 				<File
 					RelativePath="..\include\RenderingRuns\OgreFocusingMapRenderingRun.h">
+				</File>
+				<File
+					RelativePath="..\include\RenderingRuns\OgreLightVolumeRenderingRun.h">
+				</File>
+				<File
+					RelativePath="..\include\RenderingRuns\OgrePhaseTextureRenderingRun.h">
 				</File>
 				<File
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 1351)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp	(revision 1425)
@@ -29,5 +29,14 @@
 	}
 	bool visit(const Pass* p){return true;}
-	void visit(const RenderablePass* rp){}
+	void visit(const RenderablePass* rp)
+	{
+		Renderable* rend = rp->renderable; 
+		
+		if( visibleObjects->count(rend) == 0)
+		{
+			(*visibleObjects)[rend] = rend->getMaterial().getPointer()->getName();
+			rend->setMaterialName(materialName);
+		}
+	}
 
 };
@@ -107,5 +116,5 @@
 }
 
-void OgreRenderingRun::setMaterialForRenderables(String& materialName, RenderQueue* rq)
+void OgreRenderingRun::setMaterialForRenderables(String& materialName, RenderQueue* rq,  bool solidsonly)
 {
 	RenderQueue::QueueGroupIterator queueIt = rq->_getQueueGroupIterator();
@@ -124,5 +133,6 @@
 			MaterialSetVisitor visitor(materialName, &visibleObjects);	
 			solids.acceptVisitor(&visitor, QueuedRenderableCollection::OM_PASS_GROUP);
-			transparents.acceptVisitor(&visitor, QueuedRenderableCollection::OM_SORT_ASCENDING);		
+			if(!solidsonly)
+				transparents.acceptVisitor(&visitor, QueuedRenderableCollection::OM_SORT_ASCENDING);		
 		}			
     }
@@ -144,5 +154,5 @@
 }
 
-void OgreRenderingRun::setMaterialForVisibles(String& materialName, Camera* cam, bool shadowcastersonly)
+void OgreRenderingRun::setMaterialForVisibles(String& materialName, Camera* cam, bool shadowcastersonly, bool solidsonly)
 {
 	SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
@@ -160,5 +170,5 @@
 	sm->_findVisibleObjects (cam, shadowcastersonly);
 	
-	setMaterialForRenderables(materialName, rq);
+	setMaterialForRenderables(materialName, rq, solidsonly);
 }
 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderable.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderable.cpp	(revision 1062)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderable.cpp	(revision 1425)
@@ -140,6 +140,7 @@
 		 boundingSphere = billboardSetRenderable->getWorldBoundingSphere(true);*/
 		 parentParticleSystem->getParentSceneNode()->_updateBounds();
-		 boundingBox = parentParticleSystem->getWorldBoundingBox(true);
-		 boundingSphere = parentParticleSystem->getWorldBoundingSphere(true);
+		 boundingBox = parentParticleSystem->getParentSceneNode()->_getWorldAABB();
+		 boundingSphere.setRadius( (boundingBox.getMaximum() - boundingBox.getMinimum()).length() / 2.0);
+		 boundingSphere.setCenter( (boundingBox.getMaximum() + boundingBox.getMinimum()) / 2.0);
 		 break;
 	default:
@@ -176,5 +177,5 @@
 		 break;
 	 case OGRE_RENDERABLETYPE_BILLBOARDSET:
-			billboardSetRenderable->_notifyCurrentCamera(cam);		 
+			parentParticleSystem->_notifyCurrentCamera(cam);		 
 		 break;
 	default:
@@ -184,2 +185,20 @@
 	}
 }
+
+
+void OgreRenderable::updateRenderQueue(RenderQueue* rq)
+{
+	switch(renderableType)
+	{
+	 case OGRE_RENDERABLETYPE_SUBENTITY:
+			parentEntity->_updateRenderQueue(rq);
+		 break;
+	 case OGRE_RENDERABLETYPE_BILLBOARDSET:
+			parentParticleSystem->_updateRenderQueue(rq); 
+		 break;
+	default:
+		 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
+                "Unknown renderable type! Check RenderTechnique initializations!", 
+                "OgreRenderable::notifyCamera");
+	}
+}
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreLightVolumeRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreLightVolumeRenderingRun.cpp	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreLightVolumeRenderingRun.cpp	(revision 1425)
@@ -0,0 +1,218 @@
+#include "OgreLightVolumeRenderingRun.h"
+#include "OgreIlluminationManager.h"
+#include "OgreDistanceCubeMapRenderingRun.h"
+#include "OgreChildPSystemRenderingRun.h"
+
+
+
+OgreLightVolumeRenderingRun::OgreLightVolumeRenderingRun(OgreSharedRuns* sharedRuns,
+														   String name,
+														   unsigned long startFrame,
+															unsigned long updateInterval,
+															unsigned int resolution,
+															unsigned int textureDepth,
+														   String materialName
+														   )
+														   :LightVolumeRenderingRun( startFrame, updateInterval, resolution, textureDepth)
+														   , OgreRenderingRun(startFrame, updateInterval)
+														   , RenderingRun(startFrame, updateInterval)
+{
+	this->sharedRuns = sharedRuns;
+	this->name = name;	
+	this->light = 0;
+	this->materialName = materialName;
+
+	volumeBuffer = 0;
+	
+		
+
+	createLightVolumeMap();	
+}
+
+void OgreLightVolumeRenderingRun::createLightVolumeMap()
+{
+	TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name, 
+																		"default",
+																		TEX_TYPE_2D,
+																		resolution,
+																		resolution,
+																		0,																		
+																		0,
+																		PF_FLOAT16_RGBA,
+																		TU_RENDERTARGET);
+	lightVolumeTexture = texPtr.getPointer();
+	 lightVolumeCamera = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA");
+	 //add viewport to rendertarget
+	 HardwarePixelBuffer* hpb = (lightVolumeTexture->getBuffer()).getPointer();
+	 RenderTarget* rt = hpb->getRenderTarget();
+	 Viewport* v = rt->addViewport(lightVolumeCamera);
+	 //Viewport* v = rt->addViewport(OgreIlluminationManager::getSingleton().getMainCamera());
+	 v->setOverlaysEnabled(false);
+	 v->setBackgroundColour(ColourValue::White);
+	 rt->setAutoUpdated(false);
+
+	 if(textureDepth > 1)
+	 {
+		TexturePtr texPtr3D = Ogre::TextureManager::getSingleton().createManual(name + "3D", 
+																		"default",
+																		TEX_TYPE_3D,
+																		resolution,
+																		resolution,
+																		textureDepth + 1,
+																		0,
+																		PF_FLOAT16_RGBA,
+																		TU_DYNAMIC);
+		lightVolumeTexture3D = texPtr3D.getPointer();
+	 }
+}
+
+void OgreLightVolumeRenderingRun::createVolumeBuffer()
+{
+		unsigned int buffersize = resolution * resolution * 4 * 2 * (textureDepth + 1);
+		volumeBuffer = new unsigned char[buffersize];
+
+		SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
+		RenderQueue* rq = sm->getRenderQueue();
+		RenderTarget* rt = lightVolumeTexture->getBuffer().getPointer()->getRenderTarget();
+	 	rq->clear();
+		//clear screen
+		sm->setFindVisibleObjects(false);
+		rt->update();
+		sm->setFindVisibleObjects(true);
+		//copy first slice
+		PixelBox volumePB(resolution, resolution, 3,PF_FLOAT16_RGBA, volumeBuffer);
+		PixelBox pb(resolution, resolution, 1,PF_FLOAT16_RGBA, volumeBuffer);
+		lightVolumeTexture->getBuffer()->blitToMemory(pb);
+		lightVolumeTexture3D->getBuffer()->blitFromMemory(volumePB);
+	
+}
+
+void OgreLightVolumeRenderingRun::updateFrame(unsigned long frameNum)
+{
+	if(textureDepth > 1 && volumeBuffer == 0)
+		createVolumeBuffer();
+
+	refreshLight();
+
+	SceneManager* sm = Ogre::Root::getSingleton()._getCurrentSceneManager();
+	RenderQueue* rq = sm->getRenderQueue();
+	rq->clear();
+
+	//((OgreSharedRuns*)sharedRuns->getRoot(ILLUMRUN_LIGHTVOLUME_MAP))->notifyCamera(lightVolumeCamera);
+	((OgreSharedRuns*)sharedRuns->getRoot(ILLUMRUN_LIGHTVOLUME_MAP))->addRenderablesToQueue(rq, false);
+	
+	setMaterialForRenderables(materialName,rq);
+	
+	if(textureDepth == 1)
+	{
+		RenderTarget* rt = lightVolumeTexture->getBuffer().getPointer()->getRenderTarget();
+	 	rt->update();
+	}
+	else
+	{
+		//for(unsigned int i = 0; i < textureDepth; i++)
+		unsigned int i = frameNum % textureDepth;
+		{
+			//set camera nearplane
+			Matrix4 proj;
+			proj = Matrix4::IDENTITY;
+			float fustrumDepth = (i + 1) * systemRadius / ((float) textureDepth);
+			proj.setScale(Vector3(1.0 / systemRadius, 1.0 / systemRadius, -2.0 / fustrumDepth));
+			proj.setTrans(Vector3(0,0,-1));
+			lightVolumeCamera->setCustomProjectionMatrix(true,proj);
+			//render
+			RenderTarget* rt = lightVolumeTexture->getBuffer().getPointer()->getRenderTarget();
+	 		rt->update();
+			//copy texture data
+			PixelBox volumePB(resolution, resolution, textureDepth, PF_FLOAT16_RGBA, volumeBuffer);
+			PixelBox pb(resolution, resolution, 1,PF_FLOAT16_RGBA, 
+						volumeBuffer + (i + 1) * resolution * resolution * 4 * 2);
+			lightVolumeTexture->getBuffer()->blitToMemory(pb);
+			lightVolumeTexture3D->getBuffer()->blitFromMemory(volumePB);
+		}
+
+	}
+	
+	restoreMaterials();
+
+	/*
+	PixelBox volumePB(resolution, resolution, 3,PF_FLOAT16_RGBA, volumeBuffer);
+	PixelBox pb(resolution, resolution, 1,PF_FLOAT16_RGBA, volumeBuffer);
+	lightVolumeTexture->getBuffer()->blitToMemory(pb);
+	lightVolumeTexture3D->getBuffer()->blitFromMemory(volumePB);
+	*/
+	/*
+	static int framecount = 0;
+	String filename = "lightvolume";
+	filename.append(this->name);
+	//filename.append(StringConverter::toString(framecount));
+	filename.append(".bmp");
+	if(framecount % 5 == 0)
+		rt->writeContentsToFile(filename);
+	framecount++;*/
+	
+
+	
+	
+}
+
+void OgreLightVolumeRenderingRun::refreshLight()
+{
+	SceneManager* sm = Root::getSingleton()._getCurrentSceneManager();
+	LightList list;
+	sm->_populateLightList(((OgreSharedRuns*)sharedRuns)->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP),100000, list);
+	
+	light = *(list.begin());
+
+	//if herarchical
+	float baseRad = 0.0;
+	RenderingRun* run = sharedRuns->getRun(ILLUMRUN_HPP_IMPOSTOR);
+	if( run != 0)
+	{
+		OgreChildPSystemRenderingRun* rrun = (OgreChildPSystemRenderingRun*) run->asOgreRenderingRun();
+		baseRad = rrun->getSmallSysRadius();
+		//set gpu program params
+		Material* m = (Material*) MaterialManager::getSingleton().getByName(materialName).getPointer();
+		GpuProgramParametersSharedPtr vp = m->getTechnique(0)->getPass(0)->getVertexProgramParameters();
+		vp->setNamedConstant("baseRadius",baseRad);		
+	}
+
+	if(light!= 0)
+	{
+		if(light->getType() == Light::LT_DIRECTIONAL)
+		{
+			Vector3 dir = light->getDirection();
+			dir.normalise();
+			lightVolumeCamera->setDirection( dir );
+			Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_LIGHTVOLUME_MAP).getRadius();
+			r += baseRad;
+			systemRadius = r;
+			lightVolumeCamera->setPosition( sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - dir * r);
+			lightVolumeCamera->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));
+			lightVolumeCamera->setCustomProjectionMatrix(true,proj);
+		}
+		else
+		{			
+			Vector3 pos = light->getParentSceneNode()->getPosition();
+			Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - pos;
+			dir.normalise();
+			Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_LIGHTVOLUME_MAP).getRadius();
+			r += baseRad;
+			lightVolumeCamera->setPosition( sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - dir * r);
+			lightVolumeCamera->lookAt( sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) );			
+			lightVolumeCamera->setProjectionType(PT_ORTHOGRAPHIC);
+			Matrix4 proj;
+			proj = Matrix4::IDENTITY;
+			proj.setScale(Vector3(1.0/r, 1.0/r, -1/r));
+			proj.setTrans(Vector3(0,0,-1));
+			lightVolumeCamera->setCustomProjectionMatrix(true,proj);
+		}
+	}
+}
+
+
+ 
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhaseTextureRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhaseTextureRenderingRun.cpp	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhaseTextureRenderingRun.cpp	(revision 1425)
@@ -0,0 +1,47 @@
+#include "OgrePhaseTextureRenderingRun.h"
+#include "OgreIlluminationManager.h"
+
+
+OgrePhaseTextureRenderingRun::OgrePhaseTextureRenderingRun(	String name,
+														unsigned int resolutionX,
+														unsigned int resolutionY,
+														String materialName
+														   )
+														   :PhaseTextureRenderingRun(resolutionX, resolutionY)
+														   , OgreRenderingRun(1, 1)
+														   , RenderingRun(1, 1)
+{
+	this->name = name;	
+	
+	this->materialName = materialName;
+	createPhaseTexture();	
+}
+
+void OgrePhaseTextureRenderingRun::createPhaseTexture()
+{
+	
+		TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name, 
+																			"default",
+																			TEX_TYPE_2D,
+																			resolutionX,
+																			resolutionY,
+																			0,
+																			0,
+																			PF_FLOAT16_RGBA,
+																			TU_RENDERTARGET);		
+		phaseTexture = texPtr.getPointer();
+		phaseCamera = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA");
+		//add viewport to rendertarget
+		HardwarePixelBuffer* hpb = (phaseTexture->getBuffer()).getPointer();
+		RenderTarget* rt = hpb->getRenderTarget();
+		Viewport* v = rt->addViewport(phaseCamera);
+		v->setOverlaysEnabled(false);
+		rt->setAutoUpdated(false);		
+}
+
+void OgrePhaseTextureRenderingRun::updateFrame(unsigned long frameNum)
+{
+	RenderTarget* rt = phaseTexture->getBuffer().getPointer()->getRenderTarget();	
+	
+	renderFullscreenQuad(materialName, rt);	
+}
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreFocusingMapRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreFocusingMapRenderingRun.cpp	(revision 1125)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreFocusingMapRenderingRun.cpp	(revision 1425)
@@ -18,5 +18,5 @@
 	bool first = true;
 	
-	for(int i = 0; i < buffersize; i+= 4)
+	for(unsigned int i = 0; i < buffersize; i+= 4)
 	{
 		float x = floatbuffer[i];
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreSceneCameraDepthRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreSceneCameraDepthRenderingRun.cpp	(revision 874)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreSceneCameraDepthRenderingRun.cpp	(revision 1425)
@@ -43,5 +43,5 @@
 {
 	
-	setMaterialForVisibles(String("GameTools/SceneCameraDepthShader"), playerCamera);
+	setMaterialForVisibles(String("GameTools/SceneCameraDepthShader"), playerCamera, false, true);
 	
 	RenderTarget* rt = depthTexture->getBuffer().getPointer()->getRenderTarget();
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreChildParticlesystemRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreChildParticlesystemRenderingRun.cpp	(revision 1337)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreChildParticlesystemRenderingRun.cpp	(revision 1425)
@@ -69,5 +69,4 @@
 	psysNode->setPosition(center);
 	ParticleSystem* psys = Root::getSingleton()._getCurrentSceneManager()->getParticleSystem(childParticleSystemName);
-	psys->_notifyCurrentCamera(impostorCamera);
 	
 	psysNode->_updateBounds();
@@ -111,4 +110,5 @@
 
 	//
+	psys->_notifyCurrentCamera(impostorCamera);
 	psys->_updateRenderQueue(rq);
 	
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreHierarchicalParticleSystemTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreHierarchicalParticleSystemTechnique.cpp	(revision 1330)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreHierarchicalParticleSystemTechnique.cpp	(revision 1425)
@@ -3,4 +3,5 @@
 #include "OgreHierarchicalParticleSystemTechnique.h"
 #include "OgreChildPSystemRenderingRun.h"
+#include "OgreLightVolumeRenderingRun.h"
 
 OgreHierarchicalParticleSystemTechnique::OgreHierarchicalParticleSystemTechnique(
@@ -43,7 +44,7 @@
 	if(sharedRuns->getRun(ILLUMRUN_HPP_IMPOSTOR) == 0)
 		sharedRuns->addRun(ILLUMRUN_HPP_IMPOSTOR, createChildPSysRenderingRun());	
-
+	
 	((OgreChildPSystemRenderingRun*) sharedRuns->getRun(ILLUMRUN_HPP_IMPOSTOR)->asOgreRenderingRun())->setNode(node);
-	impostorChanged(sharedRuns->getRun(ILLUMRUN_HPP_IMPOSTOR));
+	impostorChanged(sharedRuns->getRun(ILLUMRUN_HPP_IMPOSTOR));	
 }
 
@@ -74,10 +75,9 @@
 }
 
-void OgreHierarchicalParticleSystemTechnique::update(unsigned long frameNum)
-{
-	HierarchicalParticleSystemTechnique::update(frameNum);
-
-	OgreChildPSystemRenderingRun* r = (OgreChildPSystemRenderingRun*) 
-											sharedRuns->getRun(ILLUMRUN_HPP_IMPOSTOR)->asOgreRenderingRun();
+
+void OgreHierarchicalParticleSystemTechnique::impostorUpdated(RenderingRun* run)
+{
+	OgreChildPSystemRenderingRun* r = (OgreChildPSystemRenderingRun*) run->asOgreRenderingRun();											
+	
 	float radius = r->getSmallSysRadius();
 	if(useVParam)
@@ -155,4 +155,5 @@
 		OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory;
 		f->VParamRadius = params;
+		f->useVParam = true;
 	}
 	void parseFparamRadius(String& params, RenderTechniqueFactory* factory)
@@ -160,4 +161,5 @@
 		OgreHierarchicalParticleSystemTechniqueFactory* f = (OgreHierarchicalParticleSystemTechniqueFactory*) factory;
 		f->FParamRadius = params;
+		f->useFParam = true;
 	}
 
@@ -180,6 +182,6 @@
 	this->attributeParsers.insert(AttribParserList::value_type("particle_script", (ILLUM_ATTRIBUTE_PARSER) parseScriptName));
 	this->attributeParsers.insert(AttribParserList::value_type("material", (ILLUM_ATTRIBUTE_PARSER) parseMaterialName));
-	this->attributeParsers.insert(AttribParserList::value_type("vparam_radius", (ILLUM_ATTRIBUTE_PARSER) parseFparamRadius));
-	this->attributeParsers.insert(AttribParserList::value_type("fparam_radius", (ILLUM_ATTRIBUTE_PARSER) parseVparamRadius));
+	this->attributeParsers.insert(AttribParserList::value_type("vparam_radius", (ILLUM_ATTRIBUTE_PARSER) parseVparamRadius));
+	this->attributeParsers.insert(AttribParserList::value_type("fparam_radius", (ILLUM_ATTRIBUTE_PARSER) parseFparamRadius));
 	
 }
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreIllumVolumeRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreIllumVolumeRenderTechnique.cpp	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreIllumVolumeRenderTechnique.cpp	(revision 1425)
@@ -0,0 +1,214 @@
+#include "OgreTechniqueGroup.h"
+#include "OgreIllumVolumeRenderTechnique.h"
+#include "OgreChildPSystemRenderingRun.h"
+#include "OgreLightVolumeRenderingRun.h"
+
+OgreIllumVolumeRenderTechnique::OgreIllumVolumeRenderTechnique(
+														unsigned long startFrame,
+														unsigned long illumVolumeUpdateInterval,
+														unsigned int illumTextureResolution,
+														unsigned int textureDepth,
+														unsigned char illumTexID,
+														bool useDistCalc,
+														String materialName,
+														String lightMatrixGPUParamName,
+														bool useHierarchicalImpostor,
+														unsigned char impostorTexID,
+														Pass* pass,
+														OgreRenderable* parentRenderable,
+														OgreTechniqueGroup* parentTechniqueGroup)
+							:OgreRenderTechnique( pass, parentRenderable, parentTechniqueGroup),
+							IllumVolumeRenderTechnique(startFrame, illumVolumeUpdateInterval, illumTextureResolution, textureDepth, useDistCalc, useHierarchicalImpostor, parentRenderable, parentTechniqueGroup),
+							RenderTechnique(parentRenderable, parentTechniqueGroup) 
+{	
+	this->illumTexID = illumTexID;
+	this->materialName = materialName;
+	this->lightMatrixGPUParamName = lightMatrixGPUParamName;
+	this->impostorTexID = impostorTexID;
+	this->lightMatrixGPUParamName = lightMatrixGPUParamName;
+	
+	if(sharedRuns->getRun(ILLUMRUN_LIGHTVOLUME_MAP) == 0)
+		sharedRuns->addRun(ILLUMRUN_LIGHTVOLUME_MAP, createLightVolumeRenderingRun());	
+	
+	lightVolumeChanged(sharedRuns->getRun(ILLUMRUN_LIGHTVOLUME_MAP));
+}
+
+
+OgreIllumVolumeRenderTechnique::~OgreIllumVolumeRenderTechnique()
+{
+
+}
+
+void OgreIllumVolumeRenderTechnique::lightVolumeChanged(RenderingRun* run)
+{
+	OgreLightVolumeRenderingRun* r = (OgreLightVolumeRenderingRun*) run->asOgreRenderingRun();
+	pass->getTextureUnitState(illumTexID)->setTextureName(r->getLightVolumeTextureName());
+}
+
+void OgreIllumVolumeRenderTechnique::lightVolumeUpdated(RenderingRun* run)
+{
+	OgreLightVolumeRenderingRun* r = (OgreLightVolumeRenderingRun*) run->asOgreRenderingRun();
+	pass->getVertexProgramParameters()->setNamedConstant(lightMatrixGPUParamName, 
+															r->getLightViewProjectionMatrix());
+}
+
+void OgreIllumVolumeRenderTechnique::hierarchicalImpostorUpdated(RenderingRun* run)
+{
+	if(useHierarchicalImpostor)
+	{
+		OgreChildPSystemRenderingRun* r = (OgreChildPSystemRenderingRun*) run->asOgreRenderingRun();
+		Material* m = (Material*) MaterialManager::getSingleton().getByName(materialName).getPointer();
+		m->getTechnique(0)->getPass(0)->getTextureUnitState(impostorTexID)
+			->setTextureName(r->getImpostorTextureName());
+	}
+}
+
+RenderingRun* OgreIllumVolumeRenderTechnique::createLightVolumeRenderingRun()
+{
+	return new OgreLightVolumeRenderingRun( (OgreSharedRuns*) parentTechniqueGroup->getSharedRuns(), 
+												parentOgreRenderable->getName()  + "_LIGHT_VOLUME",
+												startFrame,
+												illumVolumeUpdateInterval,
+												illumTextureResolution,
+												textureDepth,
+												materialName);
+}
+
+
+///Technique Parsers
+namespace IllumVolumeParsers
+{
+	void parseStartFrame(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreIllumVolumeRenderTechniqueFactory* f = (OgreIllumVolumeRenderTechniqueFactory*) factory;
+		f->startFrame =  StringConverter::parseUnsignedLong(params);
+	}
+	void parseIllumVolumeUpdateInterval(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreIllumVolumeRenderTechniqueFactory* f = (OgreIllumVolumeRenderTechniqueFactory*) factory;
+		f->illumVolumeUpdateInterval =  StringConverter::parseUnsignedLong(params);
+	}
+
+	void parseIllumTextureResolution(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreIllumVolumeRenderTechniqueFactory* f = (OgreIllumVolumeRenderTechniqueFactory*) factory;
+		f->illumTextureResolution =  StringConverter::parseUnsignedInt(params);
+	}
+	
+	void parseIllumTextureDepth(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreIllumVolumeRenderTechniqueFactory* f = (OgreIllumVolumeRenderTechniqueFactory*) factory;
+		f->textureDepth =  StringConverter::parseUnsignedInt(params);
+	}
+
+	void parseIllumTexID(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreIllumVolumeRenderTechniqueFactory* f = (OgreIllumVolumeRenderTechniqueFactory*) factory;
+		f->illumTexID =  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 parseMaterialName(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreIllumVolumeRenderTechniqueFactory* f = (OgreIllumVolumeRenderTechniqueFactory*) factory;
+		f->materialName = params;		
+	}	
+
+	void parseLightMatrixGPUParamName(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreIllumVolumeRenderTechniqueFactory* f = (OgreIllumVolumeRenderTechniqueFactory*) factory;
+		f->lightMatrixGPUParamName = params;		
+	}	
+	
+	void parseImpostorTexID(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreIllumVolumeRenderTechniqueFactory* f = (OgreIllumVolumeRenderTechniqueFactory*) factory;
+		f->impostorTexID =  StringConverter::parseUnsignedInt(params);
+	}
+	
+	void parseUseHierarchicalImpostor(String& params, RenderTechniqueFactory* factory)
+	{
+		OgreIllumVolumeRenderTechniqueFactory* f = (OgreIllumVolumeRenderTechniqueFactory*) factory;
+		f->useHierarchicalImpostor = StringConverter::parseBool(params);
+	}
+}
+///Technique factory
+OgreIllumVolumeRenderTechniqueFactory::OgreIllumVolumeRenderTechniqueFactory()
+{
+	typeName = "IllumVolume";
+
+	using namespace IllumVolumeParsers;
+
+	//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) parseIllumVolumeUpdateInterval));
+	this->attributeParsers.insert(AttribParserList::value_type("resolution", (ILLUM_ATTRIBUTE_PARSER) parseIllumTextureResolution));
+	this->attributeParsers.insert(AttribParserList::value_type("depths", (ILLUM_ATTRIBUTE_PARSER) parseIllumTextureDepth));
+	this->attributeParsers.insert(AttribParserList::value_type("texture_unit_id", (ILLUM_ATTRIBUTE_PARSER) parseIllumTexID));
+	this->attributeParsers.insert(AttribParserList::value_type("impostor_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("material", (ILLUM_ATTRIBUTE_PARSER) parseMaterialName));
+	this->attributeParsers.insert(AttribParserList::value_type("use_hier_system", (ILLUM_ATTRIBUTE_PARSER) parseUseHierarchicalImpostor));
+	this->attributeParsers.insert(AttribParserList::value_type("lightmatrix_param_name", (ILLUM_ATTRIBUTE_PARSER) parseLightMatrixGPUParamName));
+	
+}
+
+OgreRenderTechnique* OgreIllumVolumeRenderTechniqueFactory::createInstance( 
+										IllumTechniqueParams* params,
+										Pass* pass,
+										OgreRenderable* parentRenderable,
+										OgreTechniqueGroup* parentTechniqueGroup)
+{	
+	materialName = "Smoke_IllumVolume";
+	illumTexID = 2;
+	startFrame = 0;	
+	illumVolumeUpdateInterval = 1;
+	illumTextureResolution = 256;
+	textureDepth = 1;
+	useDistCalc = false;
+	lightMatrixGPUParamName = "lightViewProj";
+	impostorTexID = 0;
+	useHierarchicalImpostor = false;	
+
+	parseParams(params);
+
+	OgreIllumVolumeRenderTechnique* result = new OgreIllumVolumeRenderTechnique(
+												startFrame,
+												illumVolumeUpdateInterval,
+												illumTextureResolution,
+												textureDepth,
+												illumTexID,
+												useDistCalc,
+												materialName,
+												lightMatrixGPUParamName,
+												useHierarchicalImpostor,
+												impostorTexID,
+												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 1055)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreSharedRuns.cpp	(revision 1425)
@@ -201,5 +201,5 @@
 	float MAXRAD = 0xffffffff;
 	//check bounds
-	for(int i = 0; i < commonruns.size(); i++)
+	for(unsigned int i = 0; i < commonruns.size(); i++)
 	{
 	 
@@ -238,5 +238,5 @@
 }
 
-void OgreSharedRuns::addRenderablesToQueue(RenderQueue* rq)
+void OgreSharedRuns::addRenderablesToQueue(RenderQueue* rq, bool checkVisible)
 {
 	if(child1 != 0) //node
@@ -251,6 +251,9 @@
 		while(it != itend)
 		{		
-			if((*it).first->isVisible())
-				rq->addRenderable(((*it).first)->getRenderable());
+			if(!checkVisible || (*it).first->isVisible())
+			{
+				//rq->addRenderable(((*it).first)->getRenderable());
+				((*it).first)->updateRenderQueue(rq);
+			}
 			it++;
 		}
Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp	(revision 1130)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp	(revision 1425)
@@ -81,4 +81,5 @@
 	focusingMapSize = 32;
 	shadowMapSize = 512;
+	phaseTextureSize = 256;
 	
 	for(int i = 0; i < RUN_TYPE_COUNT; i++)
@@ -106,4 +107,6 @@
 	OgreHierarchicalParticleSystemTechniqueFactory* HPSF = new OgreHierarchicalParticleSystemTechniqueFactory();
 		addRenderTechniqueFactory(HPSF);
+	OgreIllumVolumeRenderTechniqueFactory* illumVolume = new OgreIllumVolumeRenderTechniqueFactory();
+		addRenderTechniqueFactory(illumVolume);
 }
 
@@ -397,9 +400,9 @@
 		fillVisibleList(rq);	
 
-		int l = visibleObjects.size(); //debug
+//		int l = visibleObjects.size(); //debug
 		
 		joinSharedRuns();
 
-		int ll = sharedRunRoots.size(); //debug
+//		int ll = sharedRunRoots.size(); //debug
 
 		//update precomputings				
@@ -524,9 +527,26 @@
 			
 		}
+		case ILLUMRUN_PHASE_TEXTURE:
+		if(globalSharedRuns.getRun(ILLUMRUN_PHASE_TEXTURE) == 0)
+		{
+			OgrePhaseTextureRenderingRun* run  = new OgrePhaseTextureRenderingRun(
+				"PHASE_TEXTURE",				
+				phaseTextureSize,
+				phaseTextureSize,
+				"Phase_HenyeyGreenStein");
+			globalSharedRuns.addRun(ILLUMRUN_PHASE_TEXTURE, run);			
+		}
 		break;
 	}
 }
 
-
+void OgreIlluminationManager::savePhaseTextureToFile(String filename)
+{
+	OgrePhaseTextureRenderingRun* r = (OgrePhaseTextureRenderingRun*)
+		globalSharedRuns.getRun(ILLUMRUN_PHASE_TEXTURE)->asOgreRenderingRun();
+	Texture* t = (Texture*) TextureManager::getSingleton().getByName(r->getPhaseTextureName()).getPointer();
+	
+	t->getBuffer()->getRenderTarget()->writeContentsToFile(filename);	
+}
 
 RenderingRun* OgreIlluminationManager::getGlobalRun(RenderingRunType runType)
Index: GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/SharedRuns.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/SharedRuns.h	(revision 1103)
+++ GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/SharedRuns.h	(revision 1425)
@@ -22,5 +22,7 @@
 	ILLUMRUN_SCENE_CAMERA_DEPTH,
 	ILLUMRUN_HPP_IMPOSTOR,
-	ILLUMRUN_FOCUSING_MAP
+	ILLUMRUN_FOCUSING_MAP,
+	ILLUMRUN_LIGHTVOLUME_MAP,
+	ILLUMRUN_PHASE_TEXTURE
 };
 
Index: GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderingRuns/LightVolumeRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderingRuns/LightVolumeRenderingRun.h	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderingRuns/LightVolumeRenderingRun.h	(revision 1425)
@@ -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 LightVolumeRenderingRun : 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
+	*/
+	LightVolumeRenderingRun(unsigned long startFrame,
+							unsigned long updateInterval,
+							unsigned int resolution,
+							unsigned int textureDepth)
+							:RenderingRun(startFrame, updateInterval)
+	{
+		this->resolution = resolution;
+		this->textureDepth = textureDepth;
+	}
+
+protected:
+    //inherited
+	virtual void updateFrame(unsigned long frameNum) = 0;	
+	/**
+		@brief Creates a photon hit map.
+	*/
+	virtual inline void createLightVolumeMap() = 0;	
+	/**
+		@brief the resolution of the photonmap texture that was created by this run
+	*/
+	unsigned int resolution;
+	unsigned int textureDepth;
+
+};
Index: GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderingRuns/PhaseTextureRenderingRun.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderingRuns/PhaseTextureRenderingRun.h	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderingRuns/PhaseTextureRenderingRun.h	(revision 1425)
@@ -0,0 +1,32 @@
+#pragma once
+#include "RenderingRun.h"
+
+/**
+	@brief Base abstract class that defines a rendering process that creates depth map.
+
+	The depth map stores the scene's camera space z coordinates (rendered from the player's view).
+*/
+class PhaseTextureRenderingRun : virtual public RenderingRun
+{	
+public:
+	/**
+		@brief Constructor.
+	*/
+	PhaseTextureRenderingRun(unsigned int resolutionX,
+							unsigned int resolutionY)
+							:RenderingRun(1, 1)
+	{
+		this->resolutionX = resolutionX;
+		this->resolutionY = resolutionY;
+	}
+
+protected:
+    unsigned int resolutionX;
+	unsigned int resolutionY;
+	/**
+		@brief Creates the depth map texture.
+	*/
+	virtual inline void createPhaseTexture() = 0;	
+	//inherited
+	virtual void updateFrame(unsigned long frameNum) = 0;	
+};
Index: GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderTechniques/HierarchicalParticleSystemTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderTechniques/HierarchicalParticleSystemTechnique.h	(revision 1062)
+++ GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderTechniques/HierarchicalParticleSystemTechnique.h	(revision 1425)
@@ -29,4 +29,5 @@
 	//inherited
 	void runChanged(RenderingRunType runType, RenderingRun* run);
+	void runUpdated(RenderingRunType runType, RenderingRun* run);
 
 protected:
@@ -40,6 +41,7 @@
 	bool perspectiveRendering;
 
-	virtual RenderingRun* createChildPSysRenderingRun()=0;
+	virtual RenderingRun* createChildPSysRenderingRun()=0;	
 	virtual void impostorChanged(RenderingRun* run) = 0;
+	virtual void impostorUpdated(RenderingRun* run) = 0;
 	
 };
Index: GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderTechniques/IllumVolumeRenderTechnique.h
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderTechniques/IllumVolumeRenderTechnique.h	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/RenderTechniques/IllumVolumeRenderTechnique.h	(revision 1425)
@@ -0,0 +1,50 @@
+#pragma once
+#include "RenderTechnique.h"
+
+/**
+	@brief Base abstract class of rendering a particle system with the spherical billboard method. 	
+*/
+class IllumVolumeRenderTechnique : virtual public RenderTechnique
+{
+public:
+	/**
+		@brief Constructor.
+
+		@param parentRenderable the object to operate on
+		@param parentTechniqueGroup the TechniqueGroup this RenderedTechnique is attached to
+	*/
+	IllumVolumeRenderTechnique(
+							unsigned long startFrame,
+							unsigned long illumVolumeUpdateInterval,
+							unsigned int illumTextureResolution,
+							unsigned int textureDepth,
+							bool useDistCalc,
+							bool useHierarchicalImpostor,	
+							ElementaryRenderable* parentRenderable,
+							TechniqueGroup* parentTechniqueGroup
+							);
+	~IllumVolumeRenderTechnique();
+
+	void update(unsigned long frameNum);
+
+	//inherited
+	void runChanged(RenderingRunType runType, RenderingRun* run);
+	void runUpdated(RenderingRunType runType, RenderingRun* run);
+
+protected:
+	unsigned long illumVolumeUpdateInterval;
+	unsigned int illumTextureResolution;
+	unsigned int textureDepth;
+	/**
+			@brief offset in frame number used during update
+	*/
+	unsigned long startFrame;
+	bool useDistCalc;
+	bool useHierarchicalImpostor;	
+	
+	virtual RenderingRun* createLightVolumeRenderingRun()=0;
+	virtual void lightVolumeChanged(RenderingRun* run) = 0;
+	virtual void lightVolumeUpdated(RenderingRun* run) = 0;
+	virtual void hierarchicalImpostorUpdated(RenderingRun* run) = 0;
+	
+};
Index: GTP/trunk/Lib/Illum/IllumModule/IllumModule/scripts/illummodule.vcproj
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/IllumModule/scripts/illummodule.vcproj	(revision 1055)
+++ GTP/trunk/Lib/Illum/IllumModule/IllumModule/scripts/illummodule.vcproj	(revision 1425)
@@ -158,4 +158,7 @@
 				</File>
 				<File
+					RelativePath="..\src\RenderTechniques\IllumVolumeRenderTechnique.cpp">
+				</File>
+				<File
 					RelativePath="..\src\RenderTechniques\SBBRenderTechnique.cpp">
 				</File>
@@ -178,4 +181,10 @@
 				<File
 					RelativePath="..\src\RenderingRuns\DistanceCubeMapRenderingRun.cpp">
+				</File>
+				<File
+					RelativePath="..\src\RenderingRuns\LightVolumeRenderingRun.cpp">
+				</File>
+				<File
+					RelativePath="..\src\RenderingRuns\PhaseTextureRenderingRun.cpp">
 				</File>
 				<File
@@ -236,4 +245,7 @@
 				</File>
 				<File
+					RelativePath="..\include\RenderTechniques\IllumVolumeRenderTechnique.h">
+				</File>
+				<File
 					RelativePath="..\include\RenderTechniques\SBBRenderTechnique.h">
 				</File>
@@ -256,4 +268,10 @@
 				<File
 					RelativePath="..\include\RenderingRuns\DistanceCubeMapRenderingRun.h">
+				</File>
+				<File
+					RelativePath="..\include\RenderingRuns\LightVolumeRenderingRun.h">
+				</File>
+				<File
+					RelativePath="..\include\RenderingRuns\PhaseTextureRenderingRun.h">
 				</File>
 				<File
Index: GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderingRuns/LightVolumeRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderingRuns/LightVolumeRenderingRun.cpp	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderingRuns/LightVolumeRenderingRun.cpp	(revision 1425)
@@ -0,0 +1,1 @@
+#include "LightVolumeRenderingRun.h"
Index: GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderingRuns/PhaseTextureRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderingRuns/PhaseTextureRenderingRun.cpp	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderingRuns/PhaseTextureRenderingRun.cpp	(revision 1425)
@@ -0,0 +1,1 @@
+#include "PhaseTextureRenderingRun.h"
Index: GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderTechniques/IllumVolumeRenderTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderTechniques/IllumVolumeRenderTechnique.cpp	(revision 1425)
+++ GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderTechniques/IllumVolumeRenderTechnique.cpp	(revision 1425)
@@ -0,0 +1,46 @@
+#include "IllumVolumeRenderTechnique.h"
+
+
+IllumVolumeRenderTechnique::IllumVolumeRenderTechnique(
+												unsigned long startFrame,
+												unsigned long illumVolumeUpdateInterval,
+												unsigned int illumTextureResolution,
+												unsigned int textureDepth,
+												bool useDistCalc,
+												bool useHierarchicalImpostor,	
+												ElementaryRenderable* parentRenderable,
+												TechniqueGroup* parentTechniqueGroup)
+							:RenderTechnique( parentRenderable, parentTechniqueGroup)
+{
+	this->startFrame = startFrame;
+	this->illumVolumeUpdateInterval = illumVolumeUpdateInterval;
+	this->illumTextureResolution = illumTextureResolution;
+	this->textureDepth = textureDepth;
+	this->useDistCalc = useDistCalc;
+	this->useHierarchicalImpostor = useHierarchicalImpostor;
+	
+}
+
+IllumVolumeRenderTechnique::~IllumVolumeRenderTechnique()
+{
+
+}
+
+void IllumVolumeRenderTechnique::update(unsigned long frameNum)
+{
+	sharedRuns->updateRun(ILLUMRUN_LIGHTVOLUME_MAP, frameNum);	
+}
+
+void IllumVolumeRenderTechnique::runChanged(RenderingRunType runType, RenderingRun* run)
+{
+	if(runType == ILLUMRUN_LIGHTVOLUME_MAP)
+		lightVolumeChanged(run);
+}
+
+void IllumVolumeRenderTechnique::runUpdated(RenderingRunType runType, RenderingRun* run)
+{
+	if(runType == ILLUMRUN_LIGHTVOLUME_MAP)
+		lightVolumeUpdated(run);
+	else if(runType == ILLUMRUN_HPP_IMPOSTOR)
+		hierarchicalImpostorUpdated(run);
+}
Index: GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderTechniques/HierarchicalParticleSystemTechnique.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderTechniques/HierarchicalParticleSystemTechnique.cpp	(revision 1062)
+++ GTP/trunk/Lib/Illum/IllumModule/IllumModule/src/RenderTechniques/HierarchicalParticleSystemTechnique.cpp	(revision 1425)
@@ -35,2 +35,8 @@
 }
 
+void HierarchicalParticleSystemTechnique::runUpdated(RenderingRunType runType, RenderingRun* run)
+{
+	if(runType == ILLUMRUN_HPP_IMPOSTOR)
+		impostorUpdated(run);
+}
+
