Index: trunk/BUTE/Ogre/FinalRenderingRuns/SEMFinalGatheringPass.cpp
===================================================================
--- trunk/BUTE/Ogre/FinalRenderingRuns/SEMFinalGatheringPass.cpp	(revision 125)
+++ trunk/BUTE/Ogre/FinalRenderingRuns/SEMFinalGatheringPass.cpp	(revision 125)
@@ -0,0 +1,43 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "managedogrerendertexturepass.h"
+#include "SEMFinalGatheringPass.h"
+
+SEMFinalGatheringPass::SEMFinalGatheringPass(Root* mRoot)
+:ManagedOgreRenderTexturePass(mRoot,ManagedOgreRenderTexturePass::noRenderTargetName,1,1)
+{
+	setMaterialName("EnvMap/EnvMapMaterial");
+}
+
+SEMFinalGatheringPass::~SEMFinalGatheringPass(void)
+{
+
+}
+
+void SEMFinalGatheringPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetVector3("g_EyePos",renderTargets.at(0)->getViewport(0)->getCamera()->getPosition());
+	effectWrapper->SetVector3("g_EnvMapPos",this->envMapPosition);
+	effectWrapper->SetVector3("g_SpecularColor",this->specularColor);
+	effectWrapper->SetFloat("g_Shininess",this->shininess);
+}
+
+void SEMFinalGatheringPass::onRenderEnd(NameValuePairList* namedParams){
+	effectWrapper->EndPass();
+}
+
+void SEMFinalGatheringPass::setEnvMapPostition(Vector3 envMapPosition){
+	this->envMapPosition=envMapPosition;
+}
+
+void SEMFinalGatheringPass::setSpecularColor(Vector3 specularColor){
+	this->specularColor = specularColor;
+}
+
+void SEMFinalGatheringPass::setShininess(float shininess){
+	this->shininess=shininess;
+}
+
+void SEMFinalGatheringPass::update(){
+}
Index: trunk/BUTE/Ogre/FinalRenderingRuns/SoftShadowFinalRenderingRun.cpp
===================================================================
--- trunk/BUTE/Ogre/FinalRenderingRuns/SoftShadowFinalRenderingRun.cpp	(revision 125)
+++ trunk/BUTE/Ogre/FinalRenderingRuns/SoftShadowFinalRenderingRun.cpp	(revision 125)
@@ -0,0 +1,38 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "FinalRenderingRun.h"
+
+#include "VRMRenderFinalPass.h"
+
+#include "SoftShadowFinalRenderingRun.h"
+
+
+SoftShadowFinalRenderingRun::SoftShadowFinalRenderingRun(Entity* entity)
+		:FinalRenderingRun(entity)
+{
+	iNumberOfSamples = 0;
+}
+
+
+void SoftShadowFinalRenderingRun::renderSingleEntity(RenderTarget* backBuffer, CubeMapFaces cf)
+{
+
+}
+
+const String& SoftShadowFinalRenderingRun::getSoftShadowMapTexture()
+{
+	return vRMRenderFinalPass->getMaterialName();
+}
+
+unsigned int SoftShadowFinalRenderingRun::getSoftShadowFilteringRate()
+{
+	return iNumberOfSamples;
+}	
+
+void SoftShadowFinalRenderingRun::setSoftShadowFilteringRate(unsigned int usedNumberOfSamples)
+{
+	iNumberOfSamples = usedNumberOfSamples;
+}
Index: trunk/BUTE/Ogre/FinalRenderingRuns/DEMFinalGatheringPass.cpp
===================================================================
--- trunk/BUTE/Ogre/FinalRenderingRuns/DEMFinalGatheringPass.cpp	(revision 125)
+++ trunk/BUTE/Ogre/FinalRenderingRuns/DEMFinalGatheringPass.cpp	(revision 125)
@@ -0,0 +1,38 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "managedogrerendertexturepass.h"
+#include "DEMFinalGatheringPass.h"
+
+DEMFinalGatheringPass::DEMFinalGatheringPass(Root* mRoot)
+:ManagedOgreRenderTexturePass(mRoot,ManagedOgreRenderTexturePass::noRenderTargetName,1,1)
+{
+	setMaterialName("EnvMap/EnvMapMaterial");
+}
+
+DEMFinalGatheringPass::~DEMFinalGatheringPass(void)
+{
+
+}
+
+void DEMFinalGatheringPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetVector3("g_EyePos",renderTargets.at(0)->getViewport(0)->getCamera()->getPosition());
+	effectWrapper->SetVector3("g_EnvMapPos",this->envMapPosition);
+	effectWrapper->SetVector3("g_DiffuseColor",this->diffuseColor);
+}
+
+void DEMFinalGatheringPass::onRenderEnd(NameValuePairList* namedParams){
+	effectWrapper->EndPass();
+}
+
+void DEMFinalGatheringPass::setEnvMapPosition(Vector3 envMapPosition){
+	this->envMapPosition=envMapPosition;
+}
+
+void DEMFinalGatheringPass::setDiffuseColor(Vector3 diffuseColor){
+	this->diffuseColor=diffuseColor;
+}
+
+void DEMFinalGatheringPass::update(){
+}
Index: trunk/BUTE/Ogre/FinalRenderingRuns/FEMFinalGatheringPass.cpp
===================================================================
--- trunk/BUTE/Ogre/FinalRenderingRuns/FEMFinalGatheringPass.cpp	(revision 125)
+++ trunk/BUTE/Ogre/FinalRenderingRuns/FEMFinalGatheringPass.cpp	(revision 125)
@@ -0,0 +1,38 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "managedogrerendertexturepass.h"
+#include "FEMFinalGatheringPass.h"
+
+FEMFinalGatheringPass::FEMFinalGatheringPass(Root* mRoot)
+:ManagedOgreRenderTexturePass(mRoot,ManagedOgreRenderTexturePass::noRenderTargetName,1,1)
+{
+	setMaterialName("EnvMap/EnvMapMaterial");
+}
+
+FEMFinalGatheringPass::~FEMFinalGatheringPass(void)
+{
+
+}
+
+void FEMFinalGatheringPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetVector3("g_EyePos",renderTargets.at(0)->getViewport(0)->getCamera()->getPosition());
+	effectWrapper->SetVector3("g_EnvMapPos",this->envMapPosition);
+	effectWrapper->SetFloat("g_FresnelFactor",this->fresnelFactor);
+}
+
+void FEMFinalGatheringPass::onRenderEnd(NameValuePairList* namedParams){
+	effectWrapper->EndPass();
+}
+
+void FEMFinalGatheringPass::setEnvMapPostition(Vector3 envMapPosition){
+	this->envMapPosition=envMapPosition;
+}
+
+void FEMFinalGatheringPass::setFresnelFactor(float fresnelFactor){
+	this->fresnelFactor=fresnelFactor;
+}
+
+void FEMFinalGatheringPass::update(){
+}
Index: trunk/BUTE/Ogre/FinalRenderingRuns/SEMFinalRenderingRun.cpp
===================================================================
--- trunk/BUTE/Ogre/FinalRenderingRuns/SEMFinalRenderingRun.cpp	(revision 125)
+++ trunk/BUTE/Ogre/FinalRenderingRuns/SEMFinalRenderingRun.cpp	(revision 125)
@@ -0,0 +1,55 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "managedogrerendertexturepass.h"
+#include "SEMFinalRenderingRun.h"
+
+SEMFinalRenderingRun::SEMFinalRenderingRun(Entity* entity,RenderTarget* backBuffer,const String& textureName)
+{	
+	
+	Root* mRoot=Root::getSingletonPtr();
+	OgreAssert(mRoot!=NULL,"Root is not yet generated, rendering will fail.");
+	this->entity=entity;
+	this->backBuffer=backBuffer;
+	semFinalRenderingRunPass=new SEMFinalRenderingRunPass(mRoot);
+	semFinalRenderingRunPass->addRenderTarget(backBuffer);
+	semFinalRenderingRunPass->changeTexture(textureName,0);
+}
+
+void SEMFinalRenderingRun::setEnvMapPostition(Vector3 envMapPosition){
+	semFinalRenderingRunPass->setEnvMapPostition(envMapPostion);
+}
+
+void SEMFinalRenderingRun::setSpecularColor(float specularColor){
+	semFinalRenderingRunPass->setSpecularColor(specularColor);
+}
+
+void SEMFinalRenderingRun::setShininess(float shininess){
+	semFinalRenderingRunPass->setShininess(shininess);
+}
+
+SEMFinalRenderingRun::~SEMFinalRenderingRun(void)
+{
+}
+
+void SEMFinalRenderingRun::update(void){
+	if(entity->isVisible()){
+		SceneManager::EntityIterator entityIterator=mSceneMgr->getEntityIterator();
+		while(entityIterator.hasMoreElements()){
+			Entity* entityTemp=entityIterator.getNext();
+			entityVisibilityList.push_back(entityTemp->isVisible());
+			entityTemp->setVisible(false);
+		}
+		entity->setVisible(true);
+
+		semFinalRenderingRunPass->update();
+		
+		SceneManager::EntityIterator entityIterator=mSceneMgr->getEntityIterator();
+		int elementNumber=0;
+		while(entityIterator.hasMoreElements()){
+			Entity* entity=entityIterator.getNext();
+			entity->setVisible(entityVisibilityList.at(elementNumber));
+			elementNumber++;
+		}
+		entityVisibilityList.clear();
+	}
+}
Index: trunk/BUTE/Ogre/FinalRenderingRuns/DEMFinalRenderingRun.cpp
===================================================================
--- trunk/BUTE/Ogre/FinalRenderingRuns/DEMFinalRenderingRun.cpp	(revision 125)
+++ trunk/BUTE/Ogre/FinalRenderingRuns/DEMFinalRenderingRun.cpp	(revision 125)
@@ -0,0 +1,48 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "managedogrerendertexturepass.h"
+#include "DEMFinalGatheringPass.h"
+#include "DEMFinalRenderingRun.h"
+
+DEMFinalRenderingRun::DEMFinalRenderingRun(Entity* entity)
+{	
+	Root* mRoot=Root::getSingletonPtr();
+	OgreAssert(mRoot!=NULL,"Root is not yet generated, rendering will fail.");
+	this->entity=entity;
+	demFinalRenderingRunPass=new DEMFinalGatheringPass(mRoot);
+}
+
+void DEMFinalRenderingRun::setEnvMapPostition(Vector3 envMapPosition){
+	demFinalRenderingRunPass->setEnvMapPostition(envMapPostion);
+}
+
+void DEMFinalRenderingRun::setDiffuseColor(float diffuseColor){
+	demFinalRenderingRunPass->setDiffuseColor(diffuseColor);
+}
+
+DEMFinalRenderingRun::~DEMFinalRenderingRun(void)
+{
+}
+
+void DEMFinalRenderingRun::update(void){
+	if(entity->isVisible()){
+		SceneManager::EntityIterator entityIterator=mSceneMgr->getEntityIterator();
+		while(entityIterator.hasMoreElements()){
+			Entity* entityTemp=entityIterator.getNext();
+			entityVisibilityList.push_back(entityTemp->isVisible());
+			entityTemp->setVisible(false);
+		}
+		entity->setVisible(true);
+
+		demFinalRenderingRunPass->update();
+		
+		SceneManager::EntityIterator entityIterator=mSceneMgr->getEntityIterator();
+		int elementNumber=0;
+		while(entityIterator.hasMoreElements()){
+			Entity* entity=entityIterator.getNext();
+			entity->setVisible(entityVisibilityList.at(elementNumber));
+			elementNumber++;
+		}
+		entityVisibilityList.clear();
+	}
+}
Index: trunk/BUTE/Ogre/FinalRenderingRuns/FEMFinalRenderingRun.cpp
===================================================================
--- trunk/BUTE/Ogre/FinalRenderingRuns/FEMFinalRenderingRun.cpp	(revision 125)
+++ trunk/BUTE/Ogre/FinalRenderingRuns/FEMFinalRenderingRun.cpp	(revision 125)
@@ -0,0 +1,52 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "managedogrerendertexturepass.h"
+#include "FEMFinalRenderingRunpass.h"
+#include "FEMFinalRenderingRun.h"
+
+FEMFinalRenderingRun::FEMFinalRenderingRun(Entity* entity,RenderTarget* backBuffer,const String& textureName)
+{	
+	
+	Root* mRoot=Root::getSingletonPtr();
+	OgreAssert(mRoot!=NULL,"Root is not yet generated, rendering will fail.");
+	this->entity=entity;
+	this->backBuffer=backBuffer;
+	FEMFinalRenderingRunPass=new FEMFinalRenderingRunPass(mRoot);
+	FEMFinalRenderingRunPass->addRenderTarget(backBuffer);
+	FEMFinalRenderingRunPass->changeTexture(textureName,0);
+}
+
+void FEMFinalRenderingRun::setEnvMapPostition(Vector3 envMapPosition){
+	FEMFinalRenderingRunPass->setEnvMapPostition(envMapPostion);
+}
+
+void FEMFinalRenderingRun::setFresnelFactor(float fresnelFactor){
+	FEMFinalRenderingRunPass->setFresnelFactor(fresnelFactor);
+}
+
+FEMFinalRenderingRun::~FEMFinalRenderingRun(void)
+{
+}
+
+void FEMFinalRenderingRun::update(void){
+	if(entity->isVisible()){
+		SceneManager::EntityIterator entityIterator=mSceneMgr->getEntityIterator();
+		while(entityIterator.hasMoreElements()){
+			Entity* entityTemp=entityIterator.getNext();
+			entityVisibilityList.push_back(entityTemp->isVisible());
+			entityTemp->setVisible(false);
+		}
+		entity->setVisible(true);
+
+		FEMFinalRenderingRunPass->update();
+		
+		SceneManager::EntityIterator entityIterator=mSceneMgr->getEntityIterator();
+		int elementNumber=0;
+		while(entityIterator.hasMoreElements()){
+			Entity* entity=entityIterator.getNext();
+			entity->setVisible(entityVisibilityList.at(elementNumber));
+			elementNumber++;
+		}
+		entityVisibilityList.clear();
+	}
+}
Index: trunk/BUTE/Ogre/FinalRenderingRuns/VRMRenderFinalPass.cpp
===================================================================
--- trunk/BUTE/Ogre/FinalRenderingRuns/VRMRenderFinalPass.cpp	(revision 125)
+++ trunk/BUTE/Ogre/FinalRenderingRuns/VRMRenderFinalPass.cpp	(revision 125)
@@ -0,0 +1,36 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "VRMRenderFinalPass.h"
+
+
+VRMRenderFinalPass::VRMRenderFinalPass(
+			Root* mRoot):ManagedOgreRenderTexturePass(mRoot, ManagedOgreRenderTexturePass::noRenderTargetName,1,1)
+{
+	effectWrapper->createMaterial("VRMRenderFinalPass");
+}
+
+void VRMRenderFinalPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetVertexProgramParameters();
+	effectWrapper->SetMatrix("g_mWorldViewProj",g_mWorldViewProj);
+}
+
+
+void VRMRenderFinalPass::onRenderEnd(NameValuePairList* namedParams)
+{
+	effectWrapper->EndPass();
+}
+
+Matrix4 VRMRenderFinalPass::getWorldViewProj()
+{
+	return g_mWorldViewProj;
+}
+
+void VRMRenderFinalPass::setWorldViewProj( Matrix4 matrix4 )
+{
+	g_mWorldViewProj = matrix4;
+}
Index: trunk/BUTE/Ogre/FinalRenderingRuns/CausticFinalRenderingRun.cpp
===================================================================
--- trunk/BUTE/Ogre/FinalRenderingRuns/CausticFinalRenderingRun.cpp	(revision 125)
+++ trunk/BUTE/Ogre/FinalRenderingRuns/CausticFinalRenderingRun.cpp	(revision 125)
@@ -0,0 +1,37 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "FinalRenderingRun.h"
+
+#include "CAURenderFinalPass.h"
+
+#include "CausticFinalRenderingRun.h"
+
+
+CausticFinalRenderingRun::CausticFinalRenderingRun(Entity* entity)
+		:FinalRenderingRun(entity)
+{
+	iCausticMapUpdateInterval = 0;
+}
+
+
+void CausticFinalRenderingRun::renderSingleEntity(RenderTarget* backBuffer, CubeMapFaces cf)
+{
+}
+
+const String& CausticFinalRenderingRun::getCausticMapTexture()
+{
+	return this->cAURenderFinalPass->getMaterialName();
+}
+
+unsigned int CausticFinalRenderingRun::getCausticMapUpdateInterval()
+{
+	return iCausticMapUpdateInterval;
+}	
+
+void CausticFinalRenderingRun::setCausticMapUpdateInterval(unsigned int updateIntervalNumOfFrames)
+{
+	iCausticMapUpdateInterval = updateIntervalNumOfFrames;
+}
Index: trunk/BUTE/Ogre/FinalRenderingRuns/CAURenderFinalPass.cpp
===================================================================
--- trunk/BUTE/Ogre/FinalRenderingRuns/CAURenderFinalPass.cpp	(revision 125)
+++ trunk/BUTE/Ogre/FinalRenderingRuns/CAURenderFinalPass.cpp	(revision 125)
@@ -0,0 +1,36 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "CAURenderFinalPass.h"
+
+
+CAURenderFinalPass::CAURenderFinalPass(
+			Root* mRoot):ManagedOgreRenderTexturePass(mRoot, ManagedOgreRenderTexturePass::noRenderTargetName,1,1)
+{
+	effectWrapper->createMaterial("CAURenderFinalPass");
+}
+
+void CAURenderFinalPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetVertexProgramParameters();
+	effectWrapper->SetMatrix("g_mWorldViewProj",g_mWorldViewProj);
+}
+
+
+void CAURenderFinalPass::onRenderEnd(NameValuePairList* namedParams)
+{
+	effectWrapper->EndPass();
+}
+
+Matrix4 CAURenderFinalPass::getWorldViewProj()
+{
+	return g_mWorldViewProj;
+}
+
+void CAURenderFinalPass::setWorldViewProj( Matrix4 matrix4 )
+{
+	g_mWorldViewProj = matrix4;
+}
Index: trunk/BUTE/Ogre/IlluminationManager.cpp
===================================================================
--- trunk/BUTE/Ogre/IlluminationManager.cpp	(revision 124)
+++ trunk/BUTE/Ogre/IlluminationManager.cpp	(revision 124)
@@ -0,0 +1,341 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "FinalRenderingRun.h"
+#include "illuminationmanager.h"
+
+void IlluminationManager::render(RenderTarget* rt, CubeMapFaces cf)
+{
+	static std::vector<bool> entityVisibilityList;
+	static std::vector<bool> billboardVisibilityList;
+
+	RenderSystem* renderSystem = Root::getSingleton().getRenderSystem();
+	SceneManager* sceneManager = Root::getSingleton().getSceneManager(ST_GENERIC);
+
+	const ColourValue& backgroundColour = rt->getViewport(0)->getBackgroundColour();
+
+	//save visibility (entities)
+	//set all invisible (entities)
+	{
+		SceneManager::EntityIterator ei = sceneManager->getEntityIterator();
+		while(ei.hasMoreElements())
+		{
+			Entity* entity = ei.getNext();
+			entityVisibilityList.push_back(entity->isVisible());
+			entity->setVisible(false);
+		}
+	}
+	//save visibility (billboardsets)
+	//set all invisible (billboardsets)
+	{
+		SceneManager::BillboardSetIterator bi = sceneManager->getBillboardSetIterator();
+		while(bi.hasMoreElements())
+		{
+			BillboardSet* billboard = bi.getNext();
+			billboardVisibilityList.push_back(billboard->isVisible());
+			billboard->setVisible(false);
+		}
+	}
+
+	//foreach entity prerender
+	if(performPreRenderStep)
+	{
+		SceneManager::EntityIterator ei = sceneManager->getEntityIterator();
+		while(ei.hasMoreElements())
+		{
+			UserDefinedObject* pudo = ei.getNext()->getUserObject();
+			OgreAssert(pudo && pudo->getTypeID() == MultipleUserDefinedObject::multipleUserDefinedObjectTypeId, "An entity does not contain a valid MultipleUserDefinedObject.");
+			pudo = ((MultipleUserDefinedObject*)pudo)->getUserObjectByType(EntityRenderingObject::entityRenderingObjectTypeId);
+			OgreAssert(pudo && pudo->getTypeID() == EntityRenderingObject::entityRenderingObjectTypeId, "An entity does not contain a valid EntityRenderingObject.");
+			EntityRenderingObject* eObject = (EntityRenderingObject*)pudo;
+			FinalRenderingRun* fRun = eObject->getFinalRenderingRun();
+
+			fRun->setVisible(true);
+			fRun->preRender(rt, cf);
+			fRun->setVisible(false);
+		}
+	}
+
+	//foreach entity render
+	{
+		SceneManager::EntityIterator ei = sceneManager->getEntityIterator();
+		while(ei.hasMoreElements())
+		{
+			UserDefinedObject* pudo = ei.getNext()->getUserObject();
+			OgreAssert(pudo && pudo->getTypeID() == MultipleUserDefinedObject::multipleUserDefinedObjectTypeId, "An entity does contain a valid MultipleUserDefinedObject.");
+			pudo = ((MultipleUserDefinedObject*)pudo)->getUserObjectByType(EntityRenderingObject::entityRenderingObjectTypeId);
+			OgreAssert(pudo && pudo->getTypeID() == EntityRenderingObject::entityRenderingObjectTypeId, "An entity does contain a valid EntityRenderingObject.");
+			EntityRenderingObject* eObject = (EntityRenderingObject*)pudo;
+			FinalRenderingRun* fRun = eObject->getFinalRenderingRun();
+
+			fRun->setVisible(true);
+			fRun->renderSingleEntity(rt, cf);
+			fRun->setVisible(false);
+		}
+	}
+
+	//foreach entity postrender
+	if(performPostRenderStep)
+	{
+		SceneManager::EntityIterator ei = sceneManager->getEntityIterator();
+		while(ei.hasMoreElements())
+		{
+			UserDefinedObject* pudo = ei.getNext()->getUserObject();
+			OgreAssert(pudo && pudo->getTypeID() == MultipleUserDefinedObject::multipleUserDefinedObjectTypeId, "An entity does contain a valid MultipleUserDefinedObject.");
+			pudo = ((MultipleUserDefinedObject*)pudo)->getUserObjectByType(EntityRenderingObject::entityRenderingObjectTypeId);
+			OgreAssert(pudo && pudo->getTypeID() == EntityRenderingObject::entityRenderingObjectTypeId, "An entity does contain a valid EntityRenderingObject.");
+			EntityRenderingObject* eObject = (EntityRenderingObject*)pudo;
+			FinalRenderingRun* fRun = eObject->getFinalRenderingRun();
+
+			fRun->setVisible(true);
+			fRun->postRender(rt, cf);
+			fRun->setVisible(false);
+		}
+	}
+
+	//foreach image based lighting directional light sample
+	if(performImageBasedLighting)
+	{
+		imageLightingSamplesRun.rewind();
+		while(imageLightingSamplesRun.renderNextDepthMaps())
+		{
+			//foreach entity postrender
+			{
+				SceneManager::EntityIterator ei = sceneManager->getEntityIterator();
+				while(ei.hasMoreElements())
+				{
+					UserDefinedObject* pudo = ei.getNext()->getUserObject();
+					OgreAssert(pudo && pudo->getTypeID() == MultipleUserDefinedObject::multipleUserDefinedObjectTypeId, "An entity does contain a valid MultipleUserDefinedObject.");
+					pudo = ((MultipleUserDefinedObject*)pudo)->getUserObjectByType(EntityRenderingObject::entityRenderingObjectTypeId);
+					OgreAssert(pudo && pudo->getTypeID() == EntityRenderingObject::entityRenderingObjectTypeId, "An entity does contain a valid EntityRenderingObject.");
+					EntityRenderingObject* eObject = (EntityRenderingObject*)pudo;
+					FinalRenderingRun* fRun = eObject->getFinalRenderingRun();
+
+					fRun->setVisible(true);
+					fRun->postRender(rt, cf);
+					fRun->setVisible(false);
+				}
+			}
+		}
+	}
+
+	//restore visibility (billboardsets)
+	{
+		unsigned int elementNumber = 0;
+		SceneManager::BillboardSetIterator bi = sceneManager->getBillboardSetIterator();
+		while(bi.hasMoreElements())
+		{
+			BillboardSet* billboard = bi.getNext();
+			billboard->setVisible(billboardVisibilityList.at(elementNumber++));
+		}
+		billboardVisibilityList.clear();
+	}
+
+	//render billboardsets
+
+
+	//restore visibility (entities)
+	{
+		unsigned int elementNumber = 0;
+		SceneManager::EntityIterator ei = sceneManager->getEntityIterator();
+		while(ei.hasMoreElements())
+		{
+			Entity* entity = ei.getNext();
+			entity->setVisible(entityVisibilityList.at(elementNumber++));
+		}
+		entityVisibilityList.clear();
+	}
+}
+
+void IlluminationManager::updateStaticLightData()
+{
+	RenderSystem* renderSystem = Root::getSingleton().getRenderSystem();
+	SceneManager* sceneManager = Root::getSingleton().getSceneManager(ST_GENERIC);
+
+
+	SceneManager::LightIterator li = sceneManager->getLightIterator();
+	bool pointLightUpdated[32];
+	bool spotLightUpdated[32];
+	bool directionalLightUpdated[32];
+	for(unsigned int i=0; i<32; i++)
+	{
+		pointLightUpdated[i] = spotLightUpdated[i] = directionalLightUpdated[i] = false;
+	}
+	while(li.hasMoreElements())
+	{
+		Light* light = li.getNext();
+		if(light->getType() == Light::LT_POINT && computePointLightShadows)
+		{
+			bool newLight = true;
+			for(unsigned int il=0; il < nPointLights; il++)
+			{
+				if(pointLights[il]->ogreLight == light)
+				{
+					pointLights[il]->update();
+					pointLightUpdated[il] = true;
+					newLight = false;
+					break;
+				}
+			}
+			if(newLight)
+			{
+				OgreAssert(nPointLights < 32, "More than 32 lights!");
+				if(nPointLights < nAllocatedPointLights)
+				{
+					pointLights[nPointLights]->ogreLight = light;
+					pointLights[nPointLights]->preProcRun.setLight(light);
+					nPointLights++;
+				}
+				else
+				{
+					pointLights[nPointLights] = new PointLightPreProcData();
+					pointLights[nPointLights]->ogreLight = light;
+					pointLights[nPointLights]->preProcRun.setLight(light);
+					nPointLights++;
+					nAllocatedPointLights++;
+				}
+			}
+		}
+		else if(light->getType() == Light::LT_SPOTLIGHT && computeSpotLightShadows)
+		{
+			bool newLight = true;
+			for(unsigned int il=0; il < nSpotLights; il++)
+			{
+				if(spotLights[il]->ogreLight == light)
+				{
+					spotLights[il]->update();
+					spotLightUpdated[il] = true;
+					newLight = false;
+					break;
+				}
+			}
+			if(newLight)
+			{
+				OgreAssert(nSpotLights < 32, "More than 32 lights!");
+				if(nSpotLights < nAllocatedSpotLights)
+				{
+					spotLights[nSpotLights]->ogreLight = light;
+					spotLights[nSpotLights]->preProcRun.setLight(light);
+					nSpotLights++;
+				}
+				else
+				{
+					spotLights[nSpotLights] = new SpotLightPreProcData();
+					spotLights[nSpotLights]->ogreLight = light;
+					spotLights[nSpotLights]->preProcRun.setLight(light);
+					nSpotLights++;
+					nAllocatedSpotLights++;
+				}
+			}
+		}
+		else if(light->getType() == Light::LT_DIRECTIONAL && computeDirectionalLightShadows)
+		{
+			bool newLight = true;
+			for(unsigned int il=0; il < nDirectionalLights; il++)
+			{
+				if(directionalLights[il]->ogreLight == light)
+				{
+					directionalLights[il]->update();
+					directionalLightUpdated[il] = true;
+					newLight = false;
+					break;
+				}
+			}
+			if(newLight)
+			{
+				OgreAssert(nDirectionalLights < 32, "More than 32 lights!");
+				if(nDirectionalLights < nAllocatedDirectionalLights)
+				{
+					directionalLights[nDirectionalLights]->ogreLight = light;
+					directionalLights[nDirectionalLights]->preProcRun.setLight(light);
+					nDirectionalLights++;
+				}
+				else
+				{
+					directionalLights[nDirectionalLights] = new DirectionalLightPreProcData();
+					directionalLights[nDirectionalLights]->ogreLight = light;
+					directionalLights[nDirectionalLights]->preProcRun.setLight(light);
+					nDirectionalLights++;
+					nAllocatedDirectionalLights++;
+				}
+			}
+		}
+	}
+	//dump unused lights
+}
+
+void IlluminationManager::update(unsigned long frameNumber, RenderTarget* rt, CubeMapFaces cf)
+{
+	RenderSystem* renderSystem = Root::getSingleton().getRenderSystem();
+	SceneManager* sceneManager = Root::getSingleton().getSceneManager(ST_GENERIC);
+
+
+	//update static light data
+
+
+	//foreach entity render VRM
+	{
+		SceneManager::EntityIterator ei = sceneManager->getEntityIterator();
+		while(ei.hasMoreElements())
+		{
+			UserDefinedObject* pudo = ei.getNext()->getUserObject();
+			OgreAssert(pudo && pudo->getTypeID() == MultipleUserDefinedObject::multipleUserDefinedObjectTypeId, "An entity does contain a valid MultipleUserDefinedObject.");
+			pudo = ((MultipleUserDefinedObject*)pudo)->getUserObjectByType(EntityRenderingObject::entityRenderingObjectTypeId);
+			OgreAssert(pudo && pudo->getTypeID() == EntityRenderingObject::entityRenderingObjectTypeId, "An entity does contain a valid EntityRenderingObject.");
+			EntityRenderingObject* eObject = (EntityRenderingObject*)pudo;
+			FinalRenderingRun* fRun = eObject->getFinalRenderingRun();
+
+			eObject->updateVRM(frameNumber);
+		}
+	}
+	//foreach entity render caustic map
+	{
+		SceneManager::EntityIterator ei = sceneManager->getEntityIterator();
+		while(ei.hasMoreElements())
+		{
+			UserDefinedObject* pudo = ei.getNext()->getUserObject();
+			OgreAssert(pudo && pudo->getTypeID() == MultipleUserDefinedObject::multipleUserDefinedObjectTypeId, "An entity does contain a valid MultipleUserDefinedObject.");
+			pudo = ((MultipleUserDefinedObject*)pudo)->getUserObjectByType(EntityRenderingObject::entityRenderingObjectTypeId);
+			OgreAssert(pudo && pudo->getTypeID() == EntityRenderingObject::entityRenderingObjectTypeId, "An entity does contain a valid EntityRenderingObject.");
+			EntityRenderingObject* eObject = (EntityRenderingObject*)pudo;
+			FinalRenderingRun* fRun = eObject->getFinalRenderingRun();
+
+			eObject->updateCausticMap(frameNumber);
+		}
+	}
+
+	//foreach entity render PRM
+	{
+		SceneManager::EntityIterator ei = sceneManager->getEntityIterator();
+		while(ei.hasMoreElements())
+		{
+			UserDefinedObject* pudo = ei.getNext()->getUserObject();
+			OgreAssert(pudo && pudo->getTypeID() == MultipleUserDefinedObject::multipleUserDefinedObjectTypeId, "An entity does contain a valid MultipleUserDefinedObject.");
+			pudo = ((MultipleUserDefinedObject*)pudo)->getUserObjectByType(EntityRenderingObject::entityRenderingObjectTypeId);
+			OgreAssert(pudo && pudo->getTypeID() == EntityRenderingObject::entityRenderingObjectTypeId, "An entity does contain a valid EntityRenderingObject.");
+			EntityRenderingObject* eObject = (EntityRenderingObject*)pudo;
+			FinalRenderingRun* fRun = eObject->getFinalRenderingRun();
+
+			eObject->updatePRM(frameNumber);
+		}
+	}
+
+	//foreach entity render environment map cubes
+	{
+		SceneManager::EntityIterator ei = sceneManager->getEntityIterator();
+		while(ei.hasMoreElements())
+		{
+			UserDefinedObject* pudo = ei.getNext()->getUserObject();
+			OgreAssert(pudo && pudo->getTypeID() == MultipleUserDefinedObject::multipleUserDefinedObjectTypeId, "An entity does contain a valid MultipleUserDefinedObject.");
+			pudo = ((MultipleUserDefinedObject*)pudo)->getUserObjectByType(EntityRenderingObject::entityRenderingObjectTypeId);
+			OgreAssert(pudo && pudo->getTypeID() == EntityRenderingObject::entityRenderingObjectTypeId, "An entity does contain a valid EntityRenderingObject.");
+			EntityRenderingObject* eObject = (EntityRenderingObject*)pudo;
+			FinalRenderingRun* fRun = eObject->getFinalRenderingRun();
+
+			eObject->updateEnvironmentCubes(frameNumber);
+		}
+	}
+
+	renderSystem->clearFrameBuffer(0, rt->getViewport(0)->getBackgroundColour());
+	render(rt, cf);
+}
Index: trunk/BUTE/Ogre/RenderingType.cpp
===================================================================
--- trunk/BUTE/Ogre/RenderingType.cpp	(revision 124)
+++ trunk/BUTE/Ogre/RenderingType.cpp	(revision 124)
@@ -0,0 +1,6 @@
+#include "RenderingType.h"
+
+
+const RenderingType RenderingType::LAMBERTSHADING;
+
+const RenderingType RenderingType::TEXTUREDLAMBERTSHADING;
Index: trunk/BUTE/Ogre/MultipleUserDefinedObject.cpp
===================================================================
--- trunk/BUTE/Ogre/MultipleUserDefinedObject.cpp	(revision 124)
+++ trunk/BUTE/Ogre/MultipleUserDefinedObject.cpp	(revision 124)
@@ -0,0 +1,5 @@
+#include "Ogre.h"
+#include "multipleuserdefinedobject.h"
+
+const long MultipleUserDefinedObject::multipleUserDefinedObjectTypeId(-3);
+const String MultipleUserDefinedObject::multipleUserDefinedObjectTypeName("MultipleUserDefinedObject");
Index: trunk/BUTE/Ogre/EntityRenderingObject.cpp
===================================================================
--- trunk/BUTE/Ogre/EntityRenderingObject.cpp	(revision 124)
+++ trunk/BUTE/Ogre/EntityRenderingObject.cpp	(revision 124)
@@ -0,0 +1,146 @@
+#include "Ogre.h"
+#include "RenderingType.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "FinalRenderingRun.h"
+#include "entityrenderingobject.h"
+
+#include "LightMapFinalRenderingRun.h"
+
+const long EntityRenderingObject::entityRenderingObjectTypeId(-2);
+const String EntityRenderingObject::entityRenderingObjectTypeName("EntityRenderingObject");
+
+EntityRenderingObject::EntityRenderingObject(Entity* owner, unsigned long startFrame, const RenderingType& renderingType )
+{
+	this->startFrame = startFrame;
+
+	if(renderingType.diffuseShaded &&
+		!renderingType.diffuseTextured )
+		finalRenderingRun = new LightMapFinalRenderingRun(owner);
+
+	//for all possible per entity preComputingRuns
+	if(finalRenderingRun->getLightMapUpdateInterval() != 0)
+	{
+		lightMapRun = new LightMapRun(
+				renderingType.lightMapResolutionX,
+				renderingType.lightMapResolutionY,
+				renderingType.lightMapNumberOfMipmapLevels, 
+				renderingType.lightMapLOD,
+				owner);
+		finalRenderingRun->setLightMapTexture(lightMapRun->getResultTextureName());
+	}
+	else
+		lightMapRun = NULL;
+
+	if(finalRenderingRun->getVRMUpdateInterval() != 0)
+	{
+		vrmRun = new VRMRun(
+			owner,
+			renderingType.vrmMapResolutionX,
+			renderingType.vrmMapResolutionY
+			);
+		finalRenderingRun->setVRMTexture(vrmRun->getResultTextureName());
+	}
+	else
+		vrmRun = NULL;
+
+	if(finalRenderingRun->getCausticMapUpdateInterval() != 0)
+	{
+		causticMapRun = new CausticMapRun(owner, renderingType.causticMapResolutionX, renderingType.causticMapResolutionY);
+		finalRenderingRun->setCausticMapTexture(causticMapRun->getResultTextureName());
+	}
+	else
+		vrmRun = NULL;
+
+	if(finalRenderingRun->getPRMUpdateInterval() != 0)
+	{
+		prmRun = new PRMRun(
+			owner,
+			renderingType.prmResolution,
+			renderingType.prmNEntryPoints,
+			renderingType.prmNClusters,
+			renderingType.prmTileSize
+			);
+		finalRenderingRun->setPRMTexture(prmRun->getResultTextureName());
+		finalRenderingRun->setEntryPointsTexture(prmRun->getEntryPointsTextureName());
+		finalRenderingRun->setNEntryPoints(prmRun->getNEntryPoints());
+		finalRenderingRun->setNClusters(prmRun->getNClusters());
+		finalRenderingRun->setTileSize(prmRun->getTileSize());
+	}
+	else
+		prmRun = NULL;
+
+	if(finalRenderingRun->getDiffuseEnvironmentUpdateInterval() != 0)
+	{
+		diffuseEnvironmentRun = new DiffuseEnvironmentMapRun(owner, renderingType.diffuseEnvironmentMapResolution);
+		finalRenderingRun->setDiffuseEnvironmentTextureCube(diffuseEnvironmentRun->getResultTextureName());
+	}
+	else
+		diffuseEnvironmentRun = NULL;
+
+	if(finalRenderingRun->getSpecularEnvironmentUpdateInterval() != 0)
+	{
+		specularEnvironmentRun = new SpecularEnvironmentMapRun(owner, renderingType.specularEnvironmentMapResolution);
+		finalRenderingRun->setSpecularEnvironmentTextureCube(specularEnvironmentRun->getResultTextureName());
+	}
+	else
+		specularEnvironmentRun = NULL;
+
+	if(finalRenderingRun->getFresnelEnvironmentUpdateInterval() != 0)
+	{
+		fresnelEnvironmentRun = new FresnelEnvironmentMapRun(owner, renderingType.fresnelEnvironmentMapResolution);
+		finalRenderingRun->setFresnelEnvironmentTextureCube(fresnelEnvironmentRun->getResultTextureName());
+	}
+	else
+		fresnelEnvironmentRun = NULL;
+
+}
+
+/**
+	perform preproc necessary in this frame
+*/
+void EntityRenderingObject::updateLightMap(long frameCount)
+{
+	if(finalRenderingRun->getLightMapUpdateInterval() != 0 &&
+		((frameCount - startFrame)  % finalRenderingRun->getLightMapUpdateInterval()) == 0 )
+		lightMapRun->update();
+}
+
+void EntityRenderingObject::updateVRM(long frameCount)
+{
+	if(finalRenderingRun->getVRMUpdateInterval() != 0 &&
+		((frameCount - startFrame)  % finalRenderingRun->getVRMUpdateInterval()) == 0 )
+		vrmRun->update();		
+}
+
+void EntityRenderingObject::updateCausticMap(long frameCount)
+{
+	if(finalRenderingRun->getCausticMapUpdateInterval() != 0 &&
+		((frameCount - startFrame)  % finalRenderingRun->getCausticMapUpdateInterval()) == 0 )
+		causticMapRun->update();		
+}
+
+void EntityRenderingObject::updatePRM(long frameCount)
+{
+	if(finalRenderingRun->getPRMUpdateInterval() != 0 &&
+		((frameCount - startFrame)  % finalRenderingRun->getPRMUpdateInterval()) == 0 )
+		prmRun->update();
+}
+
+void EntityRenderingObject::updateEnvironmentCubes(long frameCount)
+{
+	if(finalRenderingRun->getDiffuseEnvironmentUpdateInterval() != 0 &&
+		((frameCount - startFrame)  % finalRenderingRun->getDiffuseEnvironmentUpdateInterval()) == 0 )
+		diffuseEnvironmentRun->update();
+	if(finalRenderingRun->getSpecularEnvironmentUpdateInterval() != 0 &&
+		((frameCount - startFrame)  % finalRenderingRun->getSpecularEnvironmentUpdateInterval()) == 0 )
+		specularEnvironmentRun->update();
+	if(finalRenderingRun->getFresnelEnvironmentUpdateInterval() != 0 &&
+		((frameCount - startFrame)  % finalRenderingRun->getFresnelEnvironmentUpdateInterval()) == 0 )
+		fresnelEnvironmentRun->update();
+}
+
+EntityRenderingObject::~EntityRenderingObject(void)
+{
+	delete finalRenderingRun;
+}
Index: trunk/BUTE/Ogre/ManagedOgreRenderTexturePass.cpp
===================================================================
--- trunk/BUTE/Ogre/ManagedOgreRenderTexturePass.cpp	(revision 124)
+++ trunk/BUTE/Ogre/ManagedOgreRenderTexturePass.cpp	(revision 124)
@@ -0,0 +1,137 @@
+#include "Ogre.h"
+#include <vector>
+#include <cmath> 
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+
+
+const char* ManagedOgreRenderTexturePass::noRenderTargetName="NO_RENDER_TEXTURE";
+MovablePlane* ManagedOgreRenderTexturePass::fullScreenQuad=NULL;
+Entity* ManagedOgreRenderTexturePass::fullScreenQuadEntity=NULL;
+SceneNode* ManagedOgreRenderTexturePass::fullScreenQuadSceneNode=NULL;
+
+ManagedOgreRenderTexturePass::ManagedOgreRenderTexturePass(
+			
+			Root* mRoot, const String& renderTextureName,unsigned int width,unsigned int height,
+		 	TextureType texType , PixelFormat internalFormat, 
+			const NameValuePairList *miscParams,bool fullScreenQuadRenderer
+			
+			){
+	
+	this->mRoot=mRoot;
+	renderSystem=mRoot->getRenderSystem();
+	mSceneMgr=mRoot->getSceneManager(ST_GENERIC);
+	if(renderTextureName!=noRenderTargetName){
+		renderTexture=renderSystem->createRenderTexture(renderTextureName,width,height,texType,internalFormat,miscParams);
+		this->addRenderTarget(renderTexture);
+	}
+	if(!fullScreenQuad){
+		createFullScreenQuad();
+	}
+	this->fullScreenQuadRenderer=fullScreenQuadRenderer;
+	effectWrapper=new EffectWrapper();
+}
+
+void ManagedOgreRenderTexturePass::createFullScreenQuad(){
+	fullScreenQuad=new MovablePlane(Vector3::UNIT_Y,0.0f);
+	MeshManager::getSingleton().createPlane("FullScreenQuad", 
+        ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 
+        *fullScreenQuad, 1, 1, 
+        1, 1, true, 1, 1, 1, Vector3::UNIT_Z);
+	this->fullScreenQuadEntity=mSceneMgr->createEntity("FullScreenQuad","FullScreenQuadEntity");
+	SceneNode* rootNode = mSceneMgr->getRootSceneNode();
+	fullScreenQuadSceneNode=rootNode->createChildSceneNode();
+	mPlaneNode->attachObject(fullScreenQuadEntity);
+    mPlaneNode->attachObject(fullScreenQuad);
+	//camera setup.
+}
+
+void ManagedOgreRenderTexturePass::entityMaterialSetup(){
+	SceneManager::EntityIterator entityIterator=mSceneMgr->getEntityIterator();
+	while(entityIterator.hasMoreElements()){
+		Entity* entity=entityIterator.getNext();
+		entity->setMaterialName(this->effectWrapper->getMaterial()->getName());
+		if(fullScreenQuadRenderer){
+			entityVisibilityList.push_back(entity->isVisible());
+			entity->setVisible(false);
+		}
+	}
+	if(fullScreenQuadRenderer){
+		this->fullScreenQuadSceneNode->setVisible(true);
+	}
+}
+
+void ManagedOgreRenderTexturePass::entityMaterialCleanup(){
+	if(fullScreenQuadRenderer){
+		SceneManager::EntityIterator entityIterator=mSceneMgr->getEntityIterator();
+		int elementNumber=0;
+		while(entityIterator.hasMoreElements()){
+			Entity* entity=entityIterator.getNext();
+			entity->setVisible(entityVisibilityList.at(elementNumber));
+			elementNumber++;
+		}
+		entityVisibilityList.clear();
+		this->fullScreenQuadSceneNode->setVisible(false);
+	}
+}
+
+void ManagedOgreRenderTexturePass::update(NameValuePairList* startParams,NameValuePairList* endParams){
+	onRenderStart(startParams);
+	entityMaterialSetup();
+	RenderTarget* rt=renderTargets.at(0);
+	Matrix4* worldMatrices=new Matrix4[rt->getViewport(0)->getCamera()->getNumWorldTransforms()];
+	rt->getViewport(0)->getCamera()->getWorldTransforms(worldMatrices);
+	Matrix4 viewMatrix=renderTexture->getViewport(0)->getCamera()->getViewMatrix();
+	Matrix4 projMatrix=renderTexture->getViewport(0)->getCamera()->getProjectionMatrix();
+	std::vector<Viewport*> viewports;
+	std::vector<RenderTarget*>::iterator rtIterator;
+	for(rtIterator=renderTargets.begin();rtIterator!=renderTargets.end();rtIterator++){
+		viewports.push_back((*rtIterator)->getViewport(0));
+	}
+	Matrix4 worldMatrix = Matrix4::IDENTITY;
+	for(int i=0;i<rt->getViewport(0)->getCamera()->getNumWorldTransforms();i++){
+		worldMatrix = worldMatrix * worldMatrices[i];
+	}
+	delete[] worldMatrices;
+	mRoot->getSceneManager(ST_GENERIC)->manualRender(effectWrapper->getMaterial()->getTechnique(0)->getPass(0),viewports,this->cubeMapFaces,worldMatrix,viewMatrix,projMatrix,true);
+	entityMaterialCleanup();
+	onRenderEnd(endParams);
+}
+
+bool ManagedOgreRenderTexturePass::changeTexture(const String& textureName, unsigned short textureUnit){
+	this->effectWrapper->SetTexture(textureUnit,textureName);
+	return false;
+}
+
+bool ManagedOgreRenderTexturePass::changeMaterial(String& materialName, StringVector& newTextureNames,bool useOldTextureNames){
+	effectWrapper->createMaterial(materialName);
+	this->effectWrapper->getMaterial()->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();
+	std::vector<TextureUnitState*>::iterator iter;
+	for(iter=usedTextureUnitStates.begin();iter<usedTextureUnitStates.end();iter++){
+		usedTextureUnitStates.erase(iter);
+	}
+	if(!useOldTextureNames){
+		textureNames=newTextureNames;
+	}
+	std::vector<String>::iterator iter2;
+	int i=0;
+	for(iter2=textureNames.begin();iter2<textureNames.end();iter2++){
+		TextureUnitState* t = this->effectWrapper->getMaterial()->getTechnique(0)->getPass(0)->createTextureUnitState((*iter2),i);
+		i++;
+		usedTextureUnitStates.push_back(t);
+	}
+	return true;
+}
+
+void ManagedOgreRenderTexturePass::oneTimeRenderToTextureSetup(String& materialName,StringVector& textureNames){
+	std::vector<String>::iterator iter;
+	this->effectWrapper->getMaterial()->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();
+	int i=0;
+	for(iter=textureNames.begin();iter<textureNames.end();iter++){
+		TextureUnitState* t = this->effectWrapper->getMaterial()->getTechnique(0)->getPass(0)->createTextureUnitState((*iter),i);
+		i++;
+		usedTextureUnitStates.push_back(t);
+	}
+	effectWrapper->createMaterial(materialName);
+}
+
Index: trunk/BUTE/Ogre/PreComputingRun.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRun.cpp	(revision 124)
+++ trunk/BUTE/Ogre/PreComputingRun.cpp	(revision 124)
@@ -0,0 +1,3 @@
+#include "Ogre.h"
+#include "precomputingrun.h"
+
Index: trunk/BUTE/Ogre/RenderingRun.cpp
===================================================================
--- trunk/BUTE/Ogre/RenderingRun.cpp	(revision 124)
+++ trunk/BUTE/Ogre/RenderingRun.cpp	(revision 124)
@@ -0,0 +1,3 @@
+#include "Ogre.h"
+#include "renderingrun.h"
+
Index: trunk/BUTE/Ogre/PreComputingRuns/PhotonMapFilteringRun.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/PhotonMapFilteringRun.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/PhotonMapFilteringRun.cpp	(revision 126)
@@ -0,0 +1,51 @@
+// author:	Szabolcs Czuczor (BME-IIT)
+
+#include "PhotonMapFilteringRun.h"
+
+
+/**
+ *	@brief: Constructor.
+ */
+PhotonMapFilteringRun::PhotonMapFilteringRun(Entity* entity, const String& areaMapName, const String& unfilteredPhotonMapName)
+{
+	this->entity = entity;
+	Root* mRoot=Root::getSingletonPtr();
+	this->areaMap = TextureManager::getSingleton().load(areaMapName,"PMFTEX");
+	this->unfilteredPhotonMap = TextureManager::getSingleton().load(unfilteredPhotonMapName,"PMFTEX");
+	this->normalMapPass=new PMFNormalMapPass(mRoot,1024,1024);
+	this->photonMapFilteringPass=new PMFFilteringPass(mRoot,1024,1024);
+	this->photonMapFilteringPass->changeTexture(areaMap->getName() , 0);
+	this->photonMapFilteringPass->changeTexture(unfilteredPhotonMap->getName() , 1);
+	this->photonMapFilteringPass->changeTexture(normalMapPass->getRenderTextureName() , 2);
+	this->normalMapPass->update();
+	this->photonMapFilteringPass->update();
+}
+
+/**
+ *	@brief: Destructor.
+ */
+PhotonMapFilteringRun::~PhotonMapFilteringRun()
+{
+	delete normalMapPass;
+	delete photonMapFilteringPass;
+}
+
+void PhotonMapFilteringRun::update()
+{
+	this->normalMapPass->update();
+	this->photonMapFilteringPass->update();
+}
+
+void PhotonMapFilteringRun::init(float areaCompensation, float normalThreshold)
+{
+	if (areaCompensation >= 0.0) this->photonMapFilteringPass->setAreaCompensation(areaCompensation);
+	if (normalThreshold >= 0.0) this->photonMapFilteringPass->setNormalThreshold(normalThreshold);
+}
+
+const String& PhotonMapFilteringRun::getResultTextureName()
+{
+	return photonMapFilteringPass->getRenderTextureName();
+}
+
+
+
Index: trunk/BUTE/Ogre/PreComputingRuns/SEMEnvironmentMapPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/SEMEnvironmentMapPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/SEMEnvironmentMapPass.cpp	(revision 126)
@@ -0,0 +1,31 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "managedogrerendertexturepass.h"
+#include "SEMEnvironmentMapPass.h"
+
+SEMEnvironmentMapPass::SEMEnvironmentMapPass(Root* mRoot,unsigned int width,unsigned int height)
+			:ManagedOgreRenderTexturePass(mRoot,"EnvMapCubeTexture",width,height,TEX_TYPE_CUBE_MAP,PF_FLOAT16_RGBA)
+{
+	//setMaterialName("EnvMap/ImpostorMaterial");
+}
+
+SEMEnvironmentMapPass::~SEMEnvironmentMapPass(void){
+	
+}
+
+void SEMEnvironmentMapPass::entityMaterialSetup(){
+	
+}
+
+void SEMEnvironmentMapPass::entityMaterialCleanup(){
+	
+}
+
+void SEMEnvironmentMapPass::onRenderStart(NameValuePairList* namedParams){
+	
+}
+
+void SEMEnvironmentMapPass::onRenderEnd(NameValuePairList* namedParams){
+	
+}
+
Index: trunk/BUTE/Ogre/PreComputingRuns/CAURenderPhotonUVMapPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/CAURenderPhotonUVMapPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/CAURenderPhotonUVMapPass.cpp	(revision 126)
@@ -0,0 +1,60 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "CAURenderPhotonUVMapPass.h"
+
+
+CAURenderPhotonUVMapPass::CAURenderPhotonUVMapPass(
+			Root* mRoot,const String& renderTextureName,unsigned int width,unsigned int height,
+		 	TextureType texType , PixelFormat internalFormat ,
+			const NameValuePairList *miscParams,
+			bool fullScreenQuadRenderer):ManagedOgreRenderTexturePass(mRoot,renderTextureName,width,height,texType,internalFormat,miscParams,fullScreenQuadRenderer)
+{
+	effectWrapper->createMaterial("RenderPhotonUVMap");
+}
+
+void CAURenderPhotonUVMapPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetVertexProgramParameters();
+	effectWrapper->SetMatrix("g_mWorldEntityMesh",g_mWorldEntityMesh);
+	effectWrapper->SetMatrix("g_mWorldViewProj",g_mWorldViewProj);
+	effectWrapper->SetVector3("g_vLightPos3f",g_vLightPos3f);
+}
+
+void CAURenderPhotonUVMapPass::onRenderEnd(NameValuePairList* namedParams)
+{
+	effectWrapper->EndPass();
+}
+
+Matrix4 CAURenderPhotonUVMapPass::getWorldEntityMesh()
+{
+	return g_mWorldEntityMesh;
+}
+
+void CAURenderPhotonUVMapPass::setWorldEntityMesh( Matrix4 matrix4 )
+{
+	g_mWorldEntityMesh = matrix4;
+}
+
+Matrix4 CAURenderPhotonUVMapPass::getWorldViewProj()
+{
+	return g_mWorldViewProj;
+}
+
+void CAURenderPhotonUVMapPass::setWorldViewProj( Matrix4 matrix4 )
+{
+	g_mWorldViewProj = matrix4;
+}
+
+Vector3 CAURenderPhotonUVMapPass::getLightPos3f()
+{
+	return g_vLightPos3f;
+}
+
+void CAURenderPhotonUVMapPass::setLightPos3f( Vector3 v )
+{
+	g_vLightPos3f = v;
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/VoronoiGenerator.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/VoronoiGenerator.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/VoronoiGenerator.cpp	(revision 126)
@@ -0,0 +1,301 @@
+#include "dxstdafx.h"
+#include ".\voronoigenerator.h"
+#include <map>
+//#include <gl/gl.h>
+//#include <gl/glut.h>
+
+
+VoronoiGenerator::VoronoiGenerator(void)
+{
+}
+
+VoronoiGenerator::~VoronoiGenerator(void)
+{
+}
+
+void VoronoiGenerator::addDir(const Vector& d)
+{
+	if(dirs.size()<3)
+	{
+		dirs.push_back(d);
+		return;
+	}
+	if(dirs.size() == 3)
+	{
+		dirs.push_back(d);
+		if(
+			((dirs[0] - dirs[1]) && 
+			(dirs[0] - dirs[2]))
+			*
+			dirs[3]
+			>  0.0
+			)
+		{
+			tris.push_back(Tri(this, 0, 1, 2));
+			tris.push_back(Tri(this, 0, 3, 1));
+			tris.push_back(Tri(this, 2, 1, 3));
+			tris.push_back(Tri(this, 0, 2, 3));
+		}
+		else
+		{
+			tris.push_back(Tri(this, 0, 2, 1));
+			tris.push_back(Tri(this, 0, 1, 3));
+			tris.push_back(Tri(this, 0, 3, 2));
+			tris.push_back(Tri(this, 1, 2, 3));
+		}
+		return;
+	}
+	dirs.push_back(d);
+	std::multimap<int, int> edges;
+	int stest;
+
+	std::vector<Tri>::iterator a = tris.begin();
+	std::vector<Tri>::iterator end = tris.end();
+	while(a != end)
+	{
+		if(a->violates(d))
+		{
+			bool needsab = true, needsbc = true, needsca = true;
+			std::multimap<int, int>::iterator fnd = edges.find(a->bi);
+			while(fnd != edges.end() && fnd->first == a->bi)
+			{
+				if(fnd->second == a->ai)
+				{
+					edges.erase(fnd);
+					needsab = false;
+					break;
+				}
+				fnd++;
+			}
+			fnd = edges.find(a->ci);
+			while(fnd != edges.end() && fnd->first == a->ci)
+			{
+				if(fnd->second == a->bi)
+				{
+					edges.erase(fnd);
+					needsbc = false;
+					break;
+				}
+				fnd++;
+			}
+			fnd = edges.find(a->ai);
+			while(fnd != edges.end() && fnd->first == a->ai)
+			{
+				if(fnd->second == a->ci)
+				{
+					edges.erase(fnd);
+					needsca = false;
+					break;
+				}
+				fnd++;
+			}
+
+			if(needsab)
+				edges.insert(std::pair<int, int>(a->ai, a->bi));
+			if(needsbc)
+				edges.insert(std::pair<int, int>(a->bi, a->ci));
+			if(needsca)
+				edges.insert(std::pair<int, int>(a->ci, a->ai));
+			a = tris.erase(a);
+			end = tris.end();
+		}
+		else
+			a++;
+	}
+	std::multimap<int, int>::iterator l = edges.begin();
+	std::multimap<int, int>::iterator lend = edges.end();
+	int lastindex = dirs.size() - 1;
+	stest = edges.size();
+	while(l != lend)
+	{
+		tris.push_back(Tri(this, lastindex, l->first, l->second));
+		l++;
+	}
+}
+
+VoronoiGenerator::Tri::Tri(VoronoiGenerator* omesh, int ai, int bi, int ci)
+{
+	mesh = omesh;
+	this->ai = ai;
+	this->bi = bi;
+	this->ci = ci;
+	n = (mesh->dirs[ai] - mesh->dirs[bi]) &&
+		(mesh->dirs[ai] - mesh->dirs[ci]);
+	n.normalize();
+	r = n * mesh->dirs[ai];
+}
+
+void VoronoiGenerator::Tri::refresh()
+{
+	n = (mesh->dirs[ai] - mesh->dirs[bi]) &&
+		(mesh->dirs[ai] - mesh->dirs[ci]);
+	n.normalize();
+	r = n * mesh->dirs[ai];
+}
+
+bool VoronoiGenerator::Tri::violates(const Vector& p)
+{
+	return (p * n) > r;
+}
+
+bool VoronoiGenerator::Tri::contains(const Vector& p)
+{
+	if((p * n) < r)
+		return false;
+	Vector da = mesh->dirs[ai];
+	Vector db = mesh->dirs[bi];
+	Vector dc = mesh->dirs[ci];
+	Vector cross = da && db;
+	if(p * cross < 0.0)
+		return false;
+	cross = db && dc;
+	if(p * cross < 0.0)
+		return false;
+	cross = dc && da;
+	if(p * cross < 0.0)
+		return false;
+	return true;
+}
+
+
+void VoronoiGenerator::glDrawDelaunay(std::vector<Vector>& powers)
+{
+	/*
+	glBegin(GL_TRIANGLES);
+		std::vector<Tri>::iterator a = tris.begin();
+		std::vector<Tri>::iterator end = tris.end();
+		while(a != end)
+		{
+			glColor3d(powers[a->ai].r / 1000.0, powers[a->ai].g / 1000.0, powers[a->ai].b / 1000.0);
+			glVertex3d(dirs[a->ai].x, dirs[a->ai].y, dirs[a->ai].z);
+			glColor3d(powers[a->bi].r / 1000.0, powers[a->bi].g / 1000.0, powers[a->bi].b / 1000.0);
+			glVertex3d(dirs[a->bi].x, dirs[a->bi].y, dirs[a->bi].z);
+			glColor3d(powers[a->ci].r / 1000.0, powers[a->ci].g / 1000.0, powers[a->ci].b / 1000.0);
+			glVertex3d(dirs[a->ci].x, dirs[a->ci].y, dirs[a->ci].z);
+			a++;
+		}
+	glEnd();
+	*/
+}
+
+struct D3DVERTEX{
+	D3DXVECTOR3 pos;
+	D3DXVECTOR3 normal;
+	D3DXVECTOR2 tex0;
+	D3DXVECTOR2 tex1;
+	D3DXVECTOR3 tex2;
+};
+
+void VoronoiGenerator::d3dDrawDelaunay(LPDIRECT3DDEVICE9 device)
+{
+	std::vector<Tri>::iterator a = tris.begin();
+	std::vector<Tri>::iterator end = tris.end();
+	while(a != end)
+	{
+		D3DVERTEX tr[3];
+	    tr[0].pos=D3DXVECTOR3(dirs[a->ai].x, dirs[a->ai].y, dirs[a->ai].z);
+		tr[1].pos=D3DXVECTOR3(dirs[a->bi].x, dirs[a->bi].y, dirs[a->bi].z);
+		tr[2].pos=D3DXVECTOR3(dirs[a->ci].x, dirs[a->ci].y, dirs[a->ci].z);
+
+		device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 1, tr, sizeof(D3DVERTEX));
+		a++;
+	}
+
+
+}
+
+void VoronoiGenerator::relaxLloyd()
+{
+	double* voroAreas = new double[dirs.size()];
+	std::vector<Vector> relaxedDirs;
+	relaxedDirs.insert(relaxedDirs.begin(), dirs.size(), Vector::RGBBLACK);
+/*	for(int r=0; r<dirs.size(); r++)
+	{
+		voroAreas[r] = 0.0;
+	}*/
+
+	std::vector<Tri>::iterator a = tris.begin();
+	std::vector<Tri>::iterator end = tris.end();
+	while(a != end)
+	{
+		Vector la = (dirs[a->bi] - dirs[a->ai]);
+		Vector lb = (dirs[a->ci] - dirs[a->ai]);
+		double lcos = la * lb;
+		if(lcos >= 1.0)
+			lcos = 1.0;
+		double triArea = 
+			sqrt(la.norm2() * la.norm2() * (1.0 - lcos * lcos)) / 4.0;
+//		double lsin = sqrt(1.0 - lcos * lcos);
+//		relaxedDirs[a->ai] += a->n * lsin;
+//		relaxedDirs[a->bi] += a->n * lsin;
+//		relaxedDirs[a->ci] += a->n * lsin;
+		relaxedDirs[a->ai] += (dirs[a->ai] * 4.0 + dirs[a->bi] + dirs[a->ci]) * 0.166666666666 * triArea;
+		relaxedDirs[a->bi] += (dirs[a->ai] + dirs[a->bi] * 4.0 + dirs[a->ci]) * 0.166666666666 * triArea;
+		relaxedDirs[a->ci] += (dirs[a->ai] + dirs[a->bi] + dirs[a->ci] * 4.0) * 0.166666666666 * triArea;
+//		voroAreas[a->ai] += triArea;
+//		voroAreas[a->bi] += triArea;
+//		voroAreas[a->ci] += triArea;
+		a++;
+	}
+	std::vector<Vector>::iterator d = relaxedDirs.begin();
+	std::vector<Vector>::iterator dend = relaxedDirs.end();
+	int idx = 0;
+	while(d != dend)
+	{
+/*		if(voroAreas[idx] == 0.0)
+		{
+			char mess[200];
+			sprintf(mess, "HEY: %d", idx);
+			AfxMessageBox(mess);
+			voroAreas[idx] = 1.0;
+		}
+		(*d) *= 1.0 / voroAreas[idx];*/
+		d->normalize();
+		d++;
+		idx++;
+	}
+	dirs = relaxedDirs;
+	delete voroAreas;
+	std::vector<Tri>::iterator rfa = tris.begin();
+	std::vector<Tri>::iterator rfend = tris.end();
+	while(rfa != rfend)
+	{
+		rfa->refresh();
+		rfa++;
+	}
+}
+
+int VoronoiGenerator::lastNearestTriIndex = 0;
+
+int VoronoiGenerator::getNearestDirIndex(const Vector& pd)
+{
+	std::vector<Tri>::iterator a = tris.begin() + lastNearestTriIndex;
+	std::vector<Tri>::iterator end = tris.end();
+	std::vector<Tri>::iterator finitor = end;
+	if(lastNearestTriIndex)
+		finitor = tris.begin() + (lastNearestTriIndex - 1);
+	while(a != finitor)
+	{
+		if(a == end)
+		{
+			a = tris.begin();
+			if(a == finitor)
+				break;
+		}
+		if(a->contains(pd))
+		{
+			lastNearestTriIndex = a - tris.begin();
+			double adist = dirs[a->ai] * pd;
+			double bdist = dirs[a->bi] * pd;
+			double cdist = dirs[a->ci] * pd;
+			if(adist > bdist && adist > cdist)
+				return a->ai;
+			if(bdist > adist && bdist > cdist)
+				return a->bi;
+			if(cdist > adist && cdist > bdist)
+				return a->ci;
+		}
+		a++;
+	}
+	return 0;
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/Vector.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/Vector.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/Vector.cpp	(revision 126)
@@ -0,0 +1,5 @@
+#include "dxstdafx.h"
+#include "Vector.hpp"
+
+const Vector Vector::RGBBLACK(0.0f, 0.0f, 0.0f);
+const Vector Vector::RGBWHITE(0.9f, 0.9f, 0.9f);
Index: trunk/BUTE/Ogre/PreComputingRuns/SoftShadowMapRun.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/SoftShadowMapRun.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/SoftShadowMapRun.cpp	(revision 126)
@@ -0,0 +1,47 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+
+
+#include "VRMRun.h"
+#include "SoftShadowMapRun.h"
+
+
+SoftShadowMapRun::SoftShadowMapRun( Entity* entity )
+{
+	Root* mRoot = new Root();
+
+	this->entity = entity;
+
+	this->vRMRenderingRun = 
+		new VRMRun(entity,1024,1024);
+
+	this->vRMRenderGeometryMapPass =
+		new VRMRenderGeometryMapPass(mRoot,"GeometryMapTexture",1024,1024,TEX_TYPE_2D,PF_FLOAT32_RGBA);
+
+	this->vRMFilteringMapPass =
+		new VRMFilteringMapPass(mRoot,"FilterMapTexture",1024,1024,TEX_TYPE_2D,PF_FLOAT32_RGBA);
+}
+
+void SoftShadowMapRun::update()
+{
+	vRMRenderingRun->update();
+	vRMRenderDepthBufferMapPass->update();
+	vRMRenderGeometryMapPass->update();
+	vRMFilteringMapPass->update();
+}
+
+const String& SoftShadowMapRun::getResultTextureName()
+	{
+		return vRMFilteringMapPass->getMaterialName();
+	}
+
+SoftShadowMapRun::~SoftShadowMapRun()
+{
+	SAFE_DELETE(vRMRenderingRun);
+	SAFE_DELETE(vRMRenderDepthBufferMapPass);
+	SAFE_DELETE(vRMRenderGeometryMapPass);
+	SAFE_DELETE(vRMFilteringMapPass);
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/VRMRenderGeometryMapPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/VRMRenderGeometryMapPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/VRMRenderGeometryMapPass.cpp	(revision 126)
@@ -0,0 +1,60 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "VRMRenderGeometryMapPass.h"
+
+VRMRenderGeometryMapPass::VRMRenderGeometryMapPass(
+			Root* mRoot,const String& renderTextureName,unsigned int width,unsigned int height,
+		 	TextureType texType, PixelFormat internalFormat,
+			const NameValuePairList *miscParams,
+			bool fullScreenQuadRenderer):ManagedOgreRenderTexturePass(mRoot,renderTextureName,width,height,texType,internalFormat,miscParams,fullScreenQuadRenderer)
+{
+	effectWrapper->createMaterial("RenderGeometryTexture");
+}
+
+void VRMRenderGeometryMapPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetVertexProgramParameters();
+	effectWrapper->SetMatrix("g_mLightViewTexBias",g_mLightViewTexBias);
+	effectWrapper->SetMatrix("g_mWorldViewProj",g_mWorldViewProj);
+	effectWrapper->SetFloatArray("g_vLightPos3f",g_vLightPos3f,3);
+}
+
+
+void VRMRenderGeometryMapPass::onRenderEnd(NameValuePairList* namedParams)
+{
+	effectWrapper->EndPass();
+}
+
+Matrix4 VRMRenderGeometryMapPass::getLightViewTexBias()
+{
+	return g_mLightViewTexBias;
+}
+
+void VRMRenderGeometryMapPass::setLightViewTexBias( Matrix4 matrix4 )
+{
+	g_mLightViewTexBias = matrix4;
+}
+
+Matrix4 VRMRenderGeometryMapPass::getWorldViewProj()
+{
+	return g_mWorldViewProj;
+}
+
+void VRMRenderGeometryMapPass::setWorldViewProj( Matrix4 matrix4 )
+{
+	g_mWorldViewProj = matrix4;
+}
+
+float* VRMRenderGeometryMapPass::getLightPos3f()
+{
+	return g_vLightPos3f;
+}
+
+void VRMRenderGeometryMapPass::setLightPos3f( float* vector3 )
+{
+	g_vLightPos3f = vector3;
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/CAURenderColorDistanceCubeMapPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/CAURenderColorDistanceCubeMapPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/CAURenderColorDistanceCubeMapPass.cpp	(revision 126)
@@ -0,0 +1,61 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "CAURenderColorDistanceCubeMapPass.h"
+
+
+CAURenderColorDistanceCubeMapPass::CAURenderColorDistanceCubeMapPass(
+			Root* mRoot,const String& renderTextureName,unsigned int width,unsigned int height,
+		 	TextureType texType, PixelFormat internalFormat,
+			const NameValuePairList *miscParams,
+			bool fullScreenQuadRenderer):ManagedOgreRenderTexturePass(mRoot,renderTextureName,width,height,texType,internalFormat,miscParams,fullScreenQuadRenderer)
+{
+	effectWrapper->createMaterial("RenderRoomColorDistance");
+}
+
+void CAURenderColorDistanceCubeMapPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetVertexProgramParameters();
+	effectWrapper->SetMatrix("g_mWorldViewProj",g_mWorldViewProj);
+	effectWrapper->SetMatrix("g_mWorldView",g_mWorldView);
+	effectWrapper->SetVector3("g_vLightPos3f",g_vLightPos3f);
+}
+
+
+void CAURenderColorDistanceCubeMapPass::onRenderEnd(NameValuePairList* namedParams)
+{
+	effectWrapper->EndPass();
+}
+
+Matrix4 CAURenderColorDistanceCubeMapPass::getWorldView()
+{
+	return g_mWorldView;
+}
+
+void CAURenderColorDistanceCubeMapPass::setWorldView( Matrix4 matrix4 )
+{
+	g_mWorldView = matrix4;
+}
+
+Matrix4 CAURenderColorDistanceCubeMapPass::getWorldViewProj()
+{
+	return g_mWorldViewProj;
+}
+
+void CAURenderColorDistanceCubeMapPass::setWorldViewProj( Matrix4 matrix4 )
+{
+	g_mWorldViewProj = matrix4;
+}
+
+Vector3 CAURenderColorDistanceCubeMapPass::getLightPos3f()
+{
+	return g_vLightPos3f;
+}
+
+void CAURenderColorDistanceCubeMapPass::setLightPos3f( Vector3 v )
+{
+	g_vLightPos3f = v;
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/FresnelEnvironmentMapRun.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/FresnelEnvironmentMapRun.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/FresnelEnvironmentMapRun.cpp	(revision 126)
@@ -0,0 +1,37 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "managedogrerendertexturepass.h"
+#include "FresnelEnvironmentMapRun.h"
+
+FresnelEnvironmentMapRun::FresnelEnvironmentMapRun(Entity* entity, unsigned int resolution)
+{
+	Root* mRoot=Root::getSingletonPtr();
+	OgreAssert(mRoot!=NULL,"Root is not yet generated, rendering will fail.");
+	envMapPass=new FEMEnvironmentMapPass(mRoot,resolution, resolution);
+}
+
+FresnelEnvironmentMapRun::~FresnelEnvironmentMapRun(void)
+{
+	delete envMapPass;
+}
+
+void FresnelEnvironmentMapRun::update(){
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_POSITIVE_X);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_POSITIVE_Y);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_POSITIVE_Z);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_NEGATIVE_X);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_NEGATIVE_Y);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_NEGATIVE_Z);
+	envMapPass->update();
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/CAURenderUVCubeMapPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/CAURenderUVCubeMapPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/CAURenderUVCubeMapPass.cpp	(revision 126)
@@ -0,0 +1,39 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "CAURenderUVCubeMapPass.h"
+
+
+CAURenderUVCubeMapPass::CAURenderUVCubeMapPass(
+			Root* mRoot,const String& renderTextureName,unsigned int width,unsigned int height,
+		 	TextureType texType , PixelFormat internalFormat ,
+			const NameValuePairList *miscParams,
+			bool fullScreenQuadRenderer):ManagedOgreRenderTexturePass(mRoot,renderTextureName,width,height,texType,internalFormat,miscParams,fullScreenQuadRenderer)
+{
+	effectWrapper->createMaterial("RenderRoomUVMap");
+}
+
+void CAURenderUVCubeMapPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetVertexProgramParameters();
+	effectWrapper->SetMatrix("g_mWorldViewProj",g_mWorldViewProj);
+}
+
+
+void CAURenderUVCubeMapPass::onRenderEnd(NameValuePairList* namedParams)
+{
+	effectWrapper->EndPass();
+}
+
+Matrix4 CAURenderUVCubeMapPass::getWorldViewProj()
+{
+	return g_mWorldViewProj;
+}
+
+void CAURenderUVCubeMapPass::setWorldViewProj( Matrix4 matrix4 )
+{
+	g_mWorldViewProj = matrix4;
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/VRMRenderDepthBufferMapPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/VRMRenderDepthBufferMapPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/VRMRenderDepthBufferMapPass.cpp	(revision 126)
@@ -0,0 +1,50 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "VRMRenderDepthBufferMapPass.h"
+
+
+VRMRenderDepthBufferMapPass::VRMRenderDepthBufferMapPass(
+			Root* mRoot,const String& renderTextureName,unsigned int width,unsigned int height,
+		 	TextureType texType, PixelFormat internalFormat,
+			const NameValuePairList *miscParams,
+			bool fullScreenQuadRenderer):ManagedOgreRenderTexturePass(mRoot,renderTextureName,width,height,texType,internalFormat,miscParams,fullScreenQuadRenderer)
+{
+	effectWrapper->createMaterial("RenderRoomColorDistance");
+}
+
+void VRMRenderDepthBufferMapPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetVertexProgramParameters();
+	effectWrapper->SetMatrix("g_mLightViewTexBias",g_mLightViewTexBias);
+	effectWrapper->SetMatrix("g_mWorldViewProj",g_mWorldViewProj);
+}
+
+
+void VRMRenderDepthBufferMapPass::onRenderEnd(NameValuePairList* namedParams)
+{
+	effectWrapper->EndPass();
+}
+
+Matrix4 VRMRenderDepthBufferMapPass::getLightViewTexBias()
+{
+	return g_mLightViewTexBias;
+}
+
+void VRMRenderDepthBufferMapPass::setLightViewTexBias( Matrix4 matrix4 )
+{
+	g_mLightViewTexBias = matrix4;
+}
+
+Matrix4 VRMRenderDepthBufferMapPass::getWorldViewProj()
+{
+	return g_mWorldViewProj;
+}
+
+void VRMRenderDepthBufferMapPass::setWorldViewProj( Matrix4 matrix4 )
+{
+	g_mWorldViewProj = matrix4;
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/resolu.c
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/resolu.c	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/resolu.c	(revision 126)
@@ -0,0 +1,105 @@
+#ifndef lint
+static const char	RCSid[] = "$Id: resolu.c,v 2.4 2003/02/25 02:47:22 greg Exp $";
+#endif
+/*
+ * Read and write image resolutions.
+ *
+ * Externals declared in resolu.h
+ */
+
+//#include "copyright.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "resolu.h"
+
+
+char  resolu_buf[RESOLU_BUFLEN];	/* resolution line buffer */
+
+
+void
+fputresolu(ord, sl, ns, fp)		/* put out picture dimensions */
+int  ord;			/* scanline ordering */
+int  sl, ns;			/* scanline length and number */
+FILE  *fp;
+{
+	RESOLU  rs;
+
+	if ((rs.rt = ord) & YMAJOR) {
+		rs.xr = sl;
+		rs.yr = ns;
+	} else {
+		rs.xr = ns;
+		rs.yr = sl;
+	}
+	fputsresolu(&rs, fp);
+}
+
+
+int
+fgetresolu(sl, ns, fp)			/* get picture dimensions */
+int  *sl, *ns;			/* scanline length and number */
+FILE  *fp;
+{
+	RESOLU  rs;
+
+	if (!fgetsresolu(&rs, fp))
+		return(-1);
+	if (rs.rt & YMAJOR) {
+		*sl = rs.xr;
+		*ns = rs.yr;
+	} else {
+		*sl = rs.yr;
+		*ns = rs.xr;
+	}
+	return(rs.rt);
+}
+
+
+char *
+resolu2str(buf, rp)		/* convert resolution struct to line */
+char  *buf;
+register RESOLU  *rp;
+{
+	if (rp->rt&YMAJOR)
+		sprintf(buf, "%cY %d %cX %d\n",
+				rp->rt&YDECR ? '-' : '+', rp->yr,
+				rp->rt&XDECR ? '-' : '+', rp->xr);
+	else
+		sprintf(buf, "%cX %d %cY %d\n",
+				rp->rt&XDECR ? '-' : '+', rp->xr,
+				rp->rt&YDECR ? '-' : '+', rp->yr);
+	return(buf);
+}
+
+
+int
+str2resolu(rp, buf)		/* convert resolution line to struct */
+register RESOLU  *rp;
+char  *buf;
+{
+	register char  *xndx, *yndx;
+	register char  *cp;
+
+	if (buf == NULL)
+		return(0);
+	xndx = yndx = NULL;
+	for (cp = buf; *cp; cp++)
+		if (*cp == 'X')
+			xndx = cp;
+		else if (*cp == 'Y')
+			yndx = cp;
+	if (xndx == NULL || yndx == NULL)
+		return(0);
+	rp->rt = 0;
+	if (xndx > yndx) rp->rt |= YMAJOR;
+	if (xndx[-1] == '-') rp->rt |= XDECR;
+	if (yndx[-1] == '-') rp->rt |= YDECR;
+	if ((rp->xr = atoi(xndx+1)) <= 0)
+		return(0);
+	if ((rp->yr = atoi(yndx+1)) <= 0)
+		return(0);
+	return(1);
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/HdriSampler.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/HdriSampler.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/HdriSampler.cpp	(revision 126)
@@ -0,0 +1,299 @@
+#include "dxstdafx.h"
+#include ".\hdrisampler.h"
+#include "Vector.hpp"
+#include "color.h"
+#include "resolu.h"
+
+#define M_PI       3.14159265358979323846
+#define M_PI_2     1.57079632679489661923
+#define M_PI_4     0.785398163397448309616
+
+
+HdriSampler::HdriSampler(void)
+{
+	h2.SetBase(2);
+	h3.SetBase(3);
+	h5.SetBase(5);
+	hdriMap = NULL;
+}
+
+HdriSampler::~HdriSampler(void)
+{
+}
+
+
+Vector HdriSampler::getRadianceAt(const Vector& dir) const
+{
+	bool edge = false;
+	float xval, yval;
+	int upper, left;
+	float fx, fy, fz;
+	fx = fabsf(dir.x);
+	fy = fabsf(dir.y);
+	fz = fabsf(dir.z);
+	if(dir.z > 0.0 && fz >= fy && fz >= fx)
+	{
+		upper = resolutiony / 4;
+		left = resolutionx / 3;
+		xval = dir.x / dir.z;
+		yval = dir.y / dir.z;
+	}
+	else
+	if(dir.z < 0.0 && fz >= fy && fz >= fx)
+	{
+		upper = 3 * resolutiony / 4;
+		left = resolutionx / 3;
+		xval = - dir.x / dir.z;
+		yval = dir.y / dir.z;
+	}
+	else
+	if(dir.x > 0.0 && fx >= fy && fx >= fz)
+	{
+		upper = resolutiony / 4;
+		left = 2 * resolutionx / 3;
+		xval = - dir.z / dir.x;
+		yval = dir.y / dir.x;
+	}
+	else
+	if(dir.x < 0.0 && fx >= fy && fx >= fz)
+	{
+		upper = resolutiony / 4;
+		left = 0;
+		xval = - dir.z / dir.x;
+		yval = - dir.y / dir.x;
+	}
+	else
+	if(dir.y > 0.0 && fy >= fx && fy >= fz)
+	{
+		upper = 0;
+		left = resolutionx / 3;
+		xval = dir.x / dir.y;
+		yval = - dir.z / dir.y;
+	}
+	else
+	if(dir.y < 0.0 && fy >= fx && fy >= fz)
+	{
+		upper = resolutiony / 2;
+		left = resolutionx / 3;
+		xval = - dir.x / dir.y;
+		yval = - dir.z / dir.y;
+	}
+	else
+		edge = true;
+
+	if(!edge)
+	{
+		upper += ((-yval + 1.0f) * resolutiony) / 8.0;
+		left += ((xval + 1.0f) * resolutionx) / 6.0;
+		return hdriMap[left + upper * resolutionx];
+	}
+	else
+		return Vector::RGBBLACK;
+}
+
+double HdriSampler::getImportance(const Vector& px)
+{
+//	return 1.0;
+	Vector rad = getRadianceAt(px);
+	return rad.sum();
+}
+// HdriSampler commands
+
+
+void HdriSampler::findMaxImportance()
+{
+	maxImportance = 0.0;
+	for(int k=0; k<resolutionx; k++)
+		for(int j=0; j<resolutiony; j++)
+		{
+			double c = hdriMap[k + j * resolutionx].sum();
+			if(c > maxImportance)
+				maxImportance = c;
+		}
+}
+
+void HdriSampler::calculatePowers()
+{
+	powers.clear();
+	calculateRadii();
+	for(int i=0; i<samplePoints.size(); i++)
+	{
+		Vector bpower = getRadianceAt( samplePoints[i] );
+		bpower *= 3.14 * voronoiRadii[i] * voronoiRadii[i];
+		powers.push_back(bpower);
+	}
+	return;
+	int kbase = resolutionx/3;
+	int jbase = 0;
+	for(int k=0; k<resolutionx/3; k++)
+		for(int j=0; j<resolutiony/4; j++)
+		{
+			Vector pixdir;
+			pixdir.y = 1.0;
+			pixdir.x = ((double)k / resolutionx) * 6.0 - 1.0;
+			pixdir.z = (((double)j / resolutiony) * 8.0 - 1.0);
+			double formfactor = 1.0 / pixdir.norm2();
+			pixdir.normalize();
+			formfactor *= pixdir.y;
+			int di = voro.getNearestDirIndex(pixdir);
+			powers[di] += hdriMap[k + kbase + (j + jbase) * resolutionx] * formfactor;
+		}
+	kbase = resolutionx/3;
+	jbase = resolutiony/2;
+	for(int k=0; k<resolutionx/3; k++)
+		for(int j=0; j<resolutiony/4; j++)
+		{
+			Vector pixdir;
+			pixdir.y = -1.0;
+			pixdir.x = (((double)k / resolutionx) * 6.0 - 1.0);
+			pixdir.z = -(((double)j / resolutiony) * 8.0 - 1.0);
+			double formfactor = 1.0 / pixdir.norm2();
+			pixdir.normalize();
+			formfactor *= -pixdir.y;
+			int di = voro.getNearestDirIndex(pixdir);
+			powers[di] += hdriMap[k + kbase + (j + jbase) * resolutionx] * formfactor;
+		}
+	kbase = resolutionx/3;
+	jbase = resolutiony/4;
+	for(int k=0; k<resolutionx/3; k++)
+		for(int j=0; j<resolutiony/4; j++)
+		{
+			Vector pixdir;
+			pixdir.z = 1.0;
+			pixdir.x = ((double)k / resolutionx) * 6.0 - 1.0;
+			pixdir.y = -(((double)j / resolutiony) * 8.0 - 1.0);
+			double formfactor = 1.0 / pixdir.norm2();
+			pixdir.normalize();
+			formfactor *= pixdir.z;
+			int di = voro.getNearestDirIndex(pixdir);
+			powers[di] += hdriMap[k + kbase + (j + jbase) * resolutionx] * formfactor;
+		}
+	kbase = resolutionx/3;
+	jbase = resolutiony/4*3;
+	for(int k=0; k<resolutionx/3; k++)
+		for(int j=0; j<resolutiony/4; j++)
+
+		{
+			Vector pixdir;
+			pixdir.z = -1.0;
+			pixdir.x = (((double)k / resolutionx) * 6.0 - 1.0);
+			pixdir.y = ((double)j / resolutiony) * 8.0 - 1.0;
+			double formfactor = 1.0 / pixdir.norm2();
+			pixdir.normalize();
+			formfactor *= -pixdir.z;
+			int di = voro.getNearestDirIndex(pixdir);
+			powers[di] += hdriMap[k + kbase + (j + jbase) * resolutionx] * formfactor;
+		}
+	kbase = resolutionx/3*2;
+	jbase = resolutiony/4;
+	for(int k=0; k<resolutionx/3; k++)
+		for(int j=0; j<resolutiony/4; j++)
+		{
+			Vector pixdir;
+			pixdir.x = 1.0;
+			pixdir.z = -(((double)k / resolutionx) * 6.0 - 1.0);
+			pixdir.y = -(((double)j / resolutiony) * 8.0 - 1.0);
+			double formfactor = 1.0 / pixdir.norm2();
+			pixdir.normalize();
+			formfactor *= pixdir.x;
+			int di = voro.getNearestDirIndex(pixdir);
+			powers[di] += hdriMap[k + kbase + (j + jbase) * resolutionx] * formfactor;
+		}
+	kbase = 0;
+	jbase = resolutiony/4;
+	for(int k=0; k<resolutionx/3; k++)
+		for(int j=0; j<resolutiony/4; j++)
+		{
+			Vector pixdir;
+			pixdir.x = -1.0;
+			pixdir.z = (((double)k / resolutionx) * 6.0 - 1.0);
+			pixdir.y = -(((double)j / resolutiony) * 8.0 - 1.0);
+			double formfactor = 1.0 / pixdir.norm2();
+			pixdir.normalize();
+			formfactor *= -pixdir.x;
+			int di = voro.getNearestDirIndex(pixdir);
+			powers[di] += hdriMap[k + kbase + (j + jbase) * resolutionx] * formfactor;
+		}
+}
+
+bool HdriSampler::loadHdrFile(char* filename)
+{
+	FILE* file = fopen(filename, "r+b");
+	if(!file)
+		return false;
+	getheader(file, NULL, NULL);
+	RESOLU rs;
+	fgetsresolu(&rs, file);
+	resolutionx = scanlen(&rs);
+	resolutiony = numscans(&rs);
+	hdriMap = new Vector[resolutionx * resolutiony];
+	COLOR* loadhere = (COLOR*)hdriMap;
+	while(!feof(file))
+	{
+		freadscan(loadhere, resolutionx, file);
+		loadhere += resolutionx;
+	}
+	findMaxImportance();
+	return true;
+}
+
+void HdriSampler::generatePoints(int nSamples)
+{
+	//ASSERT(nSamples >= 4);
+	for(int i=0; i<nSamples; i++)
+	{
+		double fi = h2.Next() * 2.0 * M_PI;
+		double theta = asin(h3.Next() * 2.0 - 1);
+
+		Vector np(cos(fi) * cos(theta), sin(fi) * cos(theta), sin(theta));
+		while(getImportance(np) / maxImportance < h5.Next())
+		{
+			rejectedPoints.push_back(np);
+			fi = h2.Next() * 2.0 * M_PI;
+			theta = asin(h3.Next() * 2.0 - 1);
+			np = Vector(cos(fi) * cos(theta), sin(fi) * cos(theta), sin(theta));
+		}
+		samplePoints.push_back(np);
+		voro.addDir(np);
+	}
+//	calculatePowers();
+
+}
+
+void HdriSampler::relax(int nSteps)
+{
+	for(int i=0; i < nSteps; i++)
+		voro.relaxLloyd();
+	calculatePowers();
+}
+
+void HdriSampler::calculateRadii()
+{
+	voronoiRadii.clear();
+	for(int i=0; i<samplePoints.size(); i++)
+		voronoiRadii.push_back(0.0f);
+
+	std::vector<VoronoiGenerator::Tri>::iterator a = voro.tris.begin();
+	std::vector<VoronoiGenerator::Tri>::iterator end = voro.tris.end();
+	while(a != end)
+	{
+		Vector la = (voro.dirs[a->bi] - voro.dirs[a->ai]);
+		Vector lb = (voro.dirs[a->ci] - voro.dirs[a->ai]);
+		double lcos = la * lb;
+		if(lcos >= 1.0)
+			lcos = 1.0;
+		double triArea = 
+			sqrt(la.norm2() * la.norm2() * (1.0 - lcos * lcos)) / 4.0;
+		voronoiRadii[a->ai] += triArea;
+		voronoiRadii[a->bi] += triArea;
+		voronoiRadii[a->ci] += triArea;
+		a++;
+	}
+	float xx;
+	for(int g=0; g < samplePoints.size(); g++)
+	{	
+		xx = sqrt(voronoiRadii[g] / 3.14);
+		voronoiRadii[g] = xx;
+	}
+	return;
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/PMFFilteringPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/PMFFilteringPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/PMFFilteringPass.cpp	(revision 126)
@@ -0,0 +1,104 @@
+// author:	Szabolcs Czuczor (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "PMFFilteringPass.h"
+
+/**
+ *	@brief: Construtor.
+ */
+PMFFilteringPass::PMFFilteringPass(
+			Root* mRoot,unsigned int width,unsigned int height,
+		 	TextureType texType, PixelFormat internalFormat,
+			const NameValuePairList *miscParams,
+			bool fullScreenQuadRenderer,String renderTextureName)
+:ManagedOgreRenderTexturePass(mRoot,renderTextureName,width,height,texType,internalFormat,miscParams,fullScreenQuadRenderer)
+{
+	this->setMaterialName("PMF/PhotonMapFiltering");
+	generateFilterKernel(PMF_KT_UNIFORM, 2);
+	areaCompensation = 1.0f;
+	normalThreshold = 1.0f;
+}
+
+/**
+ *	@brief: Destructor.
+ */
+PMFFilteringPass::~PMFFilteringPass() {
+}
+
+void PMFFilteringPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetFragmentProgramParameters();
+	effectWrapper->SetFloatArray("filterKernel", f_pmfFilterKernel, 25);
+	effectWrapper->SetFloat("g_fPMTextRes",resolution);
+	effectWrapper->SetFloat("g_fAreaCompensation", areaCompensation);
+	effectWrapper->SetFloat("g_fNormalThreshold", normalThreshold);
+
+
+}
+
+void PMFFilteringPass::onRenderEnd(NameValuePairList* namedParams){
+	effectWrapper->EndPass();
+}
+
+float PMFFilteringPass::getResolution(){
+	return resolution;
+}
+
+void PMFFilteringPass::setResolution(float resolution){
+	this->resolution=resolution;
+}
+
+void PMFFilteringPass::generateFilterKernel(t_pmfKernelType kt, int kernelSize) {
+	i_pmfKernelType = kt;
+	i_pmfKernelSize = kernelSize;
+	for (int i = 0; i < 25; i++) f_pmfFilterKernel[i] = 0.0f;
+	float x;
+	int idx;
+	for (int j = 0; j <= kernelSize; j++)
+		for (int i = 0; i <= kernelSize; i++) {
+			idx = j * 5 + i;
+			x = (float)sqrt((double)(_pmf_sqr(i) + _pmf_sqr(j))) / (float)(kernelSize + 1);
+			switch (kt) {
+				case PMF_KT_UNIFORM: {
+					if (x <= (float)kernelSize) f_pmfFilterKernel[idx] = 0.5f;
+					else f_pmfFilterKernel[idx] = 0.0f;
+									} break;
+				case PMF_KT_TRIANGLE: {
+					f_pmfFilterKernel[idx] = 1.0f - x;
+									} break;
+				case PMF_KT_EPANECHNIKOV: {
+					f_pmfFilterKernel[idx] = 0.75f * (1.0f - _pmf_sqr(x));
+										} break;
+				case PMF_KT_QUARTIC: {
+					f_pmfFilterKernel[idx] = (15.0f / 16.0f) * _pmf_sqr(1.0f - _pmf_sqr(x));
+								} break;
+				case PMF_KT_TRIWEIGHT: {
+					f_pmfFilterKernel[idx] = (35.0f / 32.0f) * _pmf_cube(1.0f - _pmf_sqr(x));
+								} break;
+				case PMF_KT_GAUSS: {
+					f_pmfFilterKernel[idx] = 0.39894228f * (float)exp((double)-_pmf_sqr(x) / 2.0f);
+								} break;
+				case PMF_KT_COSINE: {
+					f_pmfFilterKernel[idx] = (float)cos((_PMF_PI / 2.0f) * x);
+								} break;
+			}
+			if ((kt != PMF_KT_GAUSS) && (x > kernelSize)) f_pmfFilterKernel[idx] = 0.0f;
+	}
+}
+
+void PMFFilteringPass::setAreaCompensation(float ac) {
+	this->areaCompensation = ac;
+}
+float PMFFilteringPass::getAreaCompensation() {
+	return this->areaCompensation;
+}
+void PMFFilteringPass::setNormalThreshold(float nt) {
+	this->normalThreshold = nt;
+}
+float PMFFilteringPass::getNormalThreshold() {
+	return this->normalThreshold;
+}
+
Index: trunk/BUTE/Ogre/PreComputingRuns/color.c
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/color.c	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/color.c	(revision 126)
@@ -0,0 +1,293 @@
+#ifndef lint
+static const char	RCSid[] = "$Id: color.c,v 2.10 2003/02/25 02:47:21 greg Exp $";
+#endif
+/*
+ *  color.c - routines for color calculations.
+ *
+ *  Externals declared in color.h
+ */
+
+//#include "copyright.h"
+
+#include  <stdio.h>
+
+#include  <stdlib.h>
+
+#include  <math.h>
+
+#include  "color.h"
+
+#define  MINELEN	8	/* minimum scanline length for encoding */
+#define  MAXELEN	0x7fff	/* maximum scanline length for encoding */
+#define  MINRUN		4	/* minimum run length */
+
+
+char *
+tempbuffer(len)			/* get a temporary buffer */
+unsigned int  len;
+{
+	static char  *tempbuf = NULL;
+	static unsigned  tempbuflen = 0;
+
+	if (len > tempbuflen) {
+		if (tempbuflen > 0)
+			tempbuf = (char *)realloc(tempbuf, len);
+		else
+			tempbuf = (char *)malloc(len);
+		tempbuflen = tempbuf==NULL ? 0 : len;
+	}
+	return(tempbuf);
+}
+
+
+int
+fwritecolrs(scanline, len, fp)		/* write out a colr scanline */
+register COLR  *scanline;
+int  len;
+register FILE  *fp;
+{
+	register int  i, j, beg, cnt = 1;
+	int  c2;
+	
+	if (len < MINELEN | len > MAXELEN)	/* OOBs, write out flat */
+		return(fwrite((char *)scanline,sizeof(COLR),len,fp) - len);
+					/* put magic header */
+	putc(2, fp);
+	putc(2, fp);
+	putc(len>>8, fp);
+	putc(len&255, fp);
+					/* put components seperately */
+	for (i = 0; i < 4; i++) {
+	    for (j = 0; j < len; j += cnt) {	/* find next run */
+		for (beg = j; beg < len; beg += cnt) {
+		    for (cnt = 1; cnt < 127 && beg+cnt < len &&
+			    scanline[beg+cnt][i] == scanline[beg][i]; cnt++)
+			;
+		    if (cnt >= MINRUN)
+			break;			/* long enough */
+		}
+		if (beg-j > 1 && beg-j < MINRUN) {
+		    c2 = j+1;
+		    while (scanline[c2++][i] == scanline[j][i])
+			if (c2 == beg) {	/* short run */
+			    putc(128+beg-j, fp);
+			    putc(scanline[j][i], fp);
+			    j = beg;
+			    break;
+			}
+		}
+		while (j < beg) {		/* write out non-run */
+		    if ((c2 = beg-j) > 128) c2 = 128;
+		    putc(c2, fp);
+		    while (c2--)
+			putc(scanline[j++][i], fp);
+		}
+		if (cnt >= MINRUN) {		/* write out run */
+		    putc(128+cnt, fp);
+		    putc(scanline[beg][i], fp);
+		} else
+		    cnt = 0;
+	    }
+	}
+	return(ferror(fp) ? -1 : 0);
+}
+
+
+static int
+oldreadcolrs(scanline, len, fp)		/* read in an old colr scanline */
+register COLR  *scanline;
+int  len;
+register FILE  *fp;
+{
+	int  rshift;
+	register int  i;
+	
+	rshift = 0;
+	
+	while (len > 0) {
+		scanline[0][RED] = getc(fp);
+		scanline[0][GRN] = getc(fp);
+		scanline[0][BLU] = getc(fp);
+		scanline[0][EXP] = getc(fp);
+		if (feof(fp) || ferror(fp))
+			return(-1);
+		if (scanline[0][RED] == 1 &&
+				scanline[0][GRN] == 1 &&
+				scanline[0][BLU] == 1) {
+			for (i = scanline[0][EXP] << rshift; i > 0; i--) {
+				copycolr(scanline[0], scanline[-1]);
+				scanline++;
+				len--;
+			}
+			rshift += 8;
+		} else {
+			scanline++;
+			len--;
+			rshift = 0;
+		}
+	}
+	return(0);
+}
+
+
+int
+freadcolrs(scanline, len, fp)		/* read in an encoded colr scanline */
+register COLR  *scanline;
+int  len;
+register FILE  *fp;
+{
+	register int  i, j;
+	int  code, val;
+					/* determine scanline type */
+	if (len < MINELEN | len > MAXELEN)
+		return(oldreadcolrs(scanline, len, fp));
+	if ((i = getc(fp)) == EOF)
+		return(-1);
+	if (i != 2) {
+		ungetc(i, fp);
+		return(oldreadcolrs(scanline, len, fp));
+	}
+	scanline[0][GRN] = getc(fp);
+	scanline[0][BLU] = getc(fp);
+	if ((i = getc(fp)) == EOF)
+		return(-1);
+	if (scanline[0][GRN] != 2 || scanline[0][BLU] & 128) {
+		scanline[0][RED] = 2;
+		scanline[0][EXP] = i;
+		return(oldreadcolrs(scanline+1, len-1, fp));
+	}
+	if ((scanline[0][BLU]<<8 | i) != len)
+		return(-1);		/* length mismatch! */
+					/* read each component */
+	for (i = 0; i < 4; i++)
+	    for (j = 0; j < len; ) {
+		if ((code = getc(fp)) == EOF)
+		    return(-1);
+		if (code > 128) {	/* run */
+		    code &= 127;
+		    if ((val = getc(fp)) == EOF)
+			return -1;
+		    while (code--)
+			scanline[j++][i] = val;
+		} else			/* non-run */
+		    while (code--) {
+			if ((val = getc(fp)) == EOF)
+			    return -1;
+			scanline[j++][i] = val;
+		    }
+	    }
+	return(0);
+}
+
+
+int
+fwritescan(scanline, len, fp)		/* write out a scanline */
+register COLOR  *scanline;
+int  len;
+FILE  *fp;
+{
+	COLR  *clrscan;
+	int  n;
+	register COLR  *sp;
+					/* get scanline buffer */
+	if ((sp = (COLR *)tempbuffer(len*sizeof(COLR))) == NULL)
+		return(-1);
+	clrscan = sp;
+					/* convert scanline */
+	n = len;
+	while (n-- > 0) {
+		setcolr(sp[0], scanline[0][RED],
+				  scanline[0][GRN],
+				  scanline[0][BLU]);
+		scanline++;
+		sp++;
+	}
+	return(fwritecolrs(clrscan, len, fp));
+}
+
+
+int
+freadscan(scanline, len, fp)		/* read in a scanline */
+register COLOR  *scanline;
+int  len;
+FILE  *fp;
+{
+	register COLR  *clrscan;
+
+	if ((clrscan = (COLR *)tempbuffer(len*sizeof(COLR))) == NULL)
+		return(-1);
+	if (freadcolrs(clrscan, len, fp) < 0)
+		return(-1);
+					/* convert scanline */
+	colr_color(scanline[0], clrscan[0]);
+	while (--len > 0) {
+		scanline++; clrscan++;
+		if (clrscan[0][RED] == clrscan[-1][RED] &&
+			    clrscan[0][GRN] == clrscan[-1][GRN] &&
+			    clrscan[0][BLU] == clrscan[-1][BLU] &&
+			    clrscan[0][EXP] == clrscan[-1][EXP])
+			copycolor(scanline[0], scanline[-1]);
+		else
+			colr_color(scanline[0], clrscan[0]);
+	}
+	return(0);
+}
+
+
+void
+setcolr(clr, r, g, b)		/* assign a short color value */
+register COLR  clr;
+double  r, g, b;
+{
+	double  d;
+	int  e;
+	
+	d = r > g ? r : g;
+	if (b > d) d = b;
+
+	if (d <= 1e-32) {
+		clr[RED] = clr[GRN] = clr[BLU] = 0;
+		clr[EXP] = 0;
+		return;
+	}
+
+	d = frexp(d, &e) * 255.9999 / d;
+
+	clr[RED] = r * d;
+	clr[GRN] = g * d;
+	clr[BLU] = b * d;
+	clr[EXP] = e + COLXS;
+}
+
+
+void
+colr_color(col, clr)		/* convert short to float color */
+register COLOR  col;
+register COLR  clr;
+{
+	double  f;
+	
+	if (clr[EXP] == 0)
+		col[RED] = col[GRN] = col[BLU] = 0.0;
+	else {
+		f = ldexp(1.0, (int)clr[EXP]-(COLXS+8));
+		col[RED] = (clr[RED] + 0.5)*f;
+		col[GRN] = (clr[GRN] + 0.5)*f;
+		col[BLU] = (clr[BLU] + 0.5)*f;
+	}
+}
+
+
+int
+bigdiff(c1, c2, md)			/* c1 delta c2 > md? */
+register COLOR  c1, c2;
+double  md;
+{
+	register int  i;
+
+	for (i = 0; i < 3; i++)
+		if (colval(c1,i)-colval(c2,i) > md*colval(c2,i) ||
+			colval(c2,i)-colval(c1,i) > md*colval(c1,i))
+			return(1);
+	return(0);
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/CausticMapRun.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/CausticMapRun.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/CausticMapRun.cpp	(revision 126)
@@ -0,0 +1,94 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "PreComputingRun.h"
+
+#include "CAURenderColorDistanceCubeMapPass.h"
+#include "CAURenderUVCubeMapPass.h"
+#include "CAURenderPhotonUVMapPass.h"
+#include "CAURenderUmbraPass.h"
+#include "CAURenderPhotonHitMapPass.h"
+#include "CAURenderRefractObjectMapPass.h"
+
+#include "CausticMapRun.h"
+
+
+CausticMapRun::CausticMapRun( Entity* entity, unsigned int width, unsigned int height)
+{
+	Root* mRoot = Root::getSingletonPtr();
+	OgreAssert(mRoot!=NULL," NULL pointer found "); 
+
+	this->entity = entity;
+
+	// CubeMap
+	this->cAURenderColorDistanceCubeMapPass =
+		new CAURenderColorDistanceCubeMapPass( mRoot,"CubeMapColorDistanceTexture",512,512,TEX_TYPE_CUBE_MAP,PF_FLOAT32_RGBA ); 
+	// CubeMap
+	this->cAURenderUVCubeMapPass =
+		new CAURenderUVCubeMapPass( mRoot,"CubeMapUVTexture",512,512,TEX_TYPE_CUBE_MAP,PF_FLOAT32_RGBA ); 
+
+	this->cAURenderPhotonUVMapPass = 
+		new CAURenderPhotonUVMapPass(mRoot,"PhotonUVMapTexture",512,512,TEX_TYPE_2D,PF_FLOAT32_RGBA);
+
+	// Uses the other Pass created texture
+	cAURenderPhotonUVMapPass->changeTexture(cAURenderUVCubeMapPass->getRenderTextureName(),0);
+
+
+	
+	this->cAURenderUmbraPass = 
+		new CAURenderUmbraPass(mRoot,"CubeMapLastTexture",512,512,TEX_TYPE_2D,PF_FLOAT32_RGBA);
+
+	// Use the same texture (CubeMapLastTexture)
+	this->cAURenderPhotonHitMapPass =
+		new CAURenderPhotonHitMapPass(mRoot);
+
+	// Use the same texture (CubeMapLastTexture)
+	this->cAURenderRefractObjectMapPass = 
+		new CAURenderRefractObjectMapPass(mRoot);
+
+	//g_pCubeMapTexture = TextureManager::getSingleton().load( cubeMapTexturePath,"Caustics");
+	//g_pPowerOfSnipetTexelTexture = TextureManager::getSingleton().load( cubeMapTexturePath,"Caustics");
+	//this->cAURenderPhotonHitMapPass->addRenderTarget(renderCubeMapLastPass->getRenderTexture());
+	//this->CubeMapLastPass=new CubeMapLastPass(CubeMapLastTextureNames,mRoot,"NO_RENDER_TARGET",1,1);
+	//TexturePtr fileTexture=TextureManager::getSingleton().load();
+	//cAURenderPhotonUVMapPass->changeTexture(fileTexture->getName(),1);
+}
+
+void CausticMapRun::update()
+{
+	cAURenderPhotonUVMapPass->update();
+	cAURenderUmbraPass->update();
+	cAURenderPhotonHitMapPass->update();
+	cAURenderRefractObjectMapPass->update();
+}
+
+void CausticMapRun::init()
+{
+	// Run just once
+	for( int i = 0; i< 6; i++ )
+	{
+		cAURenderColorDistanceCubeMapPass->clearRenderTargets();
+		cAURenderColorDistanceCubeMapPass->addRenderTarget(cAURenderColorDistanceCubeMapPass->getRenderTexture(),(CubeMapFaces)i);
+		cAURenderColorDistanceCubeMapPass->update();
+		cAURenderUVCubeMapPass->clearRenderTargets();
+		cAURenderUVCubeMapPass->addRenderTarget(cAURenderUVCubeMapPass->getRenderTexture(),(CubeMapFaces)i);
+		cAURenderUVCubeMapPass->update();
+	}
+}
+
+const String& CausticMapRun::getResultTextureName()
+	{
+		return cAURenderPhotonHitMapPass->getMaterialName();
+	}
+
+CausticMapRun::~CausticMapRun()
+{
+	SAFE_DELETE(cAURenderColorDistanceCubeMapPass);
+	SAFE_DELETE(cAURenderUVCubeMapPass);
+	SAFE_DELETE(cAURenderPhotonUVMapPass);
+	SAFE_DELETE(cAURenderUmbraPass);
+	SAFE_DELETE(cAURenderPhotonHitMapPass);
+	SAFE_DELETE(cAURenderRefractObjectMapPass);
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/DEMEnvironmentMapPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/DEMEnvironmentMapPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/DEMEnvironmentMapPass.cpp	(revision 126)
@@ -0,0 +1,31 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "managedogrerendertexturepass.h"
+#include "DEMEnvironmentMapPass.h"
+
+DEMEnvironmentMapPass::DEMEnvironmentMapPass(Root* mRoot,unsigned int width,unsigned int height)
+			:ManagedOgreRenderTexturePass(mRoot,"DiffuseEnvMapCubeTexture",width,height,TEX_TYPE_CUBE_MAP,PF_FLOAT16_RGBA)
+{
+	//setMaterialName("DiffuseEnvMap/ImpostorMaterial");
+}
+
+DEMEnvironmentMapPass::~DEMEnvironmentMapPass(void){
+	
+}
+
+void DEMEnvironmentMapPass::entityMaterialSetup(){
+	
+}
+
+void DEMEnvironmentMapPass::entityMaterialCleanup(){
+	
+}
+
+void DEMEnvironmentMapPass::onRenderStart(NameValuePairList* namedParams){
+	
+}
+
+void DEMEnvironmentMapPass::onRenderEnd(NameValuePairList* namedParams){
+	
+}
+
Index: trunk/BUTE/Ogre/PreComputingRuns/PMFNormalMapPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/PMFNormalMapPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/PMFNormalMapPass.cpp	(revision 126)
@@ -0,0 +1,36 @@
+// author:	Szabolcs Czuczor (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "PMFNormalMapPass.h"
+
+/**
+ *	@brief: Construtor.
+ */
+PMFNormalMapPass::PMFNormalMapPass(
+			Root* mRoot,unsigned int width,unsigned int height,
+		 	TextureType texType, PixelFormat internalFormat,
+			const NameValuePairList *miscParams,
+			bool fullScreenQuadRenderer,String renderTextureName)
+:ManagedOgreRenderTexturePass(mRoot,renderTextureName,width,height,texType,internalFormat,miscParams,fullScreenQuadRenderer)
+{
+	this->setMaterialName("PMF/NormalMap");
+}
+
+/**
+ *	@brief: Destructor.
+ */
+PMFNormalMapPass::~PMFNormalMapPass() {
+}
+
+
+void PMFNormalMapPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+}
+
+void PMFNormalMapPass::onRenderEnd(NameValuePairList* namedParams){
+	effectWrapper->EndPass();
+}
+
Index: trunk/BUTE/Ogre/PreComputingRuns/FEMEnvironmentMapPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/FEMEnvironmentMapPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/FEMEnvironmentMapPass.cpp	(revision 126)
@@ -0,0 +1,31 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "managedogrerendertexturepass.h"
+#include "FEMEnvironmentMapPass.h"
+
+FEMEnvironmentMapPass::FEMEnvironmentMapPass(Root* mRoot,unsigned int width,unsigned int height)
+			:ManagedOgreRenderTexturePass(mRoot,"EnvMapCubeTexture",width,height,TEX_TYPE_CUBE_MAP,PF_FLOAT16_RGBA)
+{
+	//setMaterialName("EnvMap/ImpostorMaterial");
+}
+
+FEMEnvironmentMapPass::~FEMEnvironmentMapPass(void){
+	
+}
+
+void FEMEnvironmentMapPass::entityMaterialSetup(){
+	
+}
+
+void FEMEnvironmentMapPass::entityMaterialCleanup(){
+	
+}
+
+void FEMEnvironmentMapPass::onRenderStart(NameValuePairList* namedParams){
+	
+}
+
+void FEMEnvironmentMapPass::onRenderEnd(NameValuePairList* namedParams){
+	
+}
+
Index: trunk/BUTE/Ogre/PreComputingRuns/CAURenderUmbraPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/CAURenderUmbraPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/CAURenderUmbraPass.cpp	(revision 126)
@@ -0,0 +1,56 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "CAURenderUmbraPass.h"
+
+
+CAURenderUmbraPass::CAURenderUmbraPass(
+			Root* mRoot,
+			const String& renderTextureName,
+			unsigned int width,
+			unsigned int height,
+		 	TextureType texType,
+			PixelFormat internalFormat,
+			const NameValuePairList *miscParams,
+			bool fullScreenQuadRenderer):ManagedOgreRenderTexturePass(mRoot,renderTextureName,width,height,texType,internalFormat,miscParams,fullScreenQuadRenderer)
+{
+	effectWrapper->createMaterial("RenderUmbra");
+}
+
+void CAURenderUmbraPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetVertexProgramParameters();
+	effectWrapper->SetVector3("g_vLightPos3f",g_vLightPos3f);
+	effectWrapper->SetFragmentProgramParameters();
+	effectWrapper->SetVector3("g_vLightPos3f",g_vLightPos3f);
+	effectWrapper->SetVector3("g_vEntityPos3f",g_vEntityPos3f);
+}
+
+
+void CAURenderUmbraPass::onRenderEnd(NameValuePairList* namedParams)
+{
+	effectWrapper->EndPass();
+}
+
+Vector3 CAURenderUmbraPass::getLightPos3f()
+{
+	return g_vLightPos3f;
+}
+
+void CAURenderUmbraPass::setLightPos3f( Vector3 vector3 )
+{
+	g_vLightPos3f = vector3;
+}
+
+Vector3 CAURenderUmbraPass::getEntityPos3f()
+{
+	return g_vEntityPos3f;
+}
+
+void CAURenderUmbraPass::setEntityPos3f( Vector3 vector3 )
+{
+	g_vEntityPos3f = vector3;
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/SpecularEnvironmentMapRun.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/SpecularEnvironmentMapRun.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/SpecularEnvironmentMapRun.cpp	(revision 126)
@@ -0,0 +1,38 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "managedogrerendertexturepass.h"
+#include "SEMEnvironmentMapPass.h"
+#include "SpecularEnvironmentMapRun.h"
+
+SpecularEnvironmentMapRun::SpecularEnvironmentMapRun(Entity* entity, unsigned int resolution)
+{
+	Root* mRoot=Root::getSingletonPtr();
+	OgreAssert(mRoot!=NULL,"Root is not yet generated, rendering will fail.");
+	envMapPass=new SEMEnvironmentMapPass(mRoot,resolution,resolution);
+}
+
+SpecularEnvironmentMapRun::~SpecularEnvironmentMapRun(void)
+{
+	delete envMapPass;
+}
+
+void SpecularEnvironmentMapRun::update(){
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_POSITIVE_X);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_POSITIVE_Y);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_POSITIVE_Z);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_NEGATIVE_X);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_NEGATIVE_Y);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_NEGATIVE_Z);
+	envMapPass->update();
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/header.c
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/header.c	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/header.c	(revision 126)
@@ -0,0 +1,322 @@
+#ifndef lint
+static const char	RCSid[] = "$Id: header.c,v 2.13 2003/03/10 17:13:29 greg Exp $";
+#endif
+/*
+ *  header.c - routines for reading and writing information headers.
+ *
+ *  Externals declared in resolu.h
+ *
+ *  newheader(t,fp)	start new information header identified by string t
+ *  isheadid(s)		returns true if s is a header id line
+ *  headidval(r,s)	copy header identifier value in s to r
+ *  dateval(t,s)	get capture date value
+ *  isdate(s)		returns true if s is a date line
+ *  fputdate(t,fp)	put out the given capture date and time
+ *  fputnow(fp)		put out the current date and time
+ *  printargs(ac,av,fp) print an argument list to fp, followed by '\n'
+ *  isformat(s)		returns true if s is of the form "FORMAT=*"
+ *  formatval(r,s)	copy the format value in s to r
+ *  fputformat(s,fp)	write "FORMAT=%s" to fp
+ *  getheader(fp,f,p)	read header from fp, calling f(s,p) on each line
+ *  globmatch(pat, str)	check for glob match of str against pat
+ *  checkheader(i,p,o)	check header format from i against p and copy to o
+ *
+ *  To copy header from input to output, use getheader(fin, fputs, fout)
+ */
+
+//#include "copyright.h"
+
+#include  <stdio.h>
+#include  <string.h>
+#include  <time.h>
+#include  <ctype.h>
+
+#define	 MAXLINE	512
+
+char  HDRSTR[] = "#?";		/* information header magic number */
+
+char  FMTSTR[] = "FORMAT=";	/* format identifier */
+
+char  TMSTR[] = "CAPDATE=";	/* capture date identifier */
+
+static int mycheck();
+
+
+void
+newheader(s, fp)		/* identifying line of information header */
+char  *s;
+register FILE  *fp;
+{
+	fputs(HDRSTR, fp);
+	fputs(s, fp);
+	putc('\n', fp);
+}
+
+
+int
+headidval(r,s)			/* get header id (return true if is id) */
+register char  *r, *s;
+{
+	register char  *cp = HDRSTR;
+
+	while (*cp) if (*cp++ != *s++) return(0);
+	if (r == NULL) return(1);
+	while (*s && !isspace(*s)) *r++ = *s++;
+	*r = '\0';
+	return(1);
+}
+
+
+int
+isheadid(s)			/* check to see if line is header id */
+char  *s;
+{
+	return(headidval(NULL, s));
+}
+
+
+int
+dateval(tloc, s)		/* get capture date value */
+time_t	*tloc;
+char	*s;
+{
+	struct tm	tms;
+	register char  *cp = TMSTR;
+
+	while (*cp) if (*cp++ != *s++) return(0);
+	while (isspace(*s)) s++;
+	if (!*s) return(0);
+	if (sscanf(s, "%d:%d:%d %d:%d:%d",
+			&tms.tm_year, &tms.tm_mon, &tms.tm_mday,
+			&tms.tm_hour, &tms.tm_min, &tms.tm_sec) != 6)
+		return(0);
+	if (tloc == NULL)
+		return(1);
+	tms.tm_mon--;
+	tms.tm_year -= 1900;
+	tms.tm_isdst = -1;	/* ask mktime() to figure out DST */
+	*tloc = mktime(&tms);
+	return(1);
+}
+
+
+int
+isdate(s)			/* is the given line a capture date? */
+char *s;
+{
+	return(dateval(NULL, s));
+}
+
+
+void
+fputdate(tv, fp)		/* write out the given time value */
+time_t	tv;
+FILE	*fp;
+{
+	struct tm	*tm = localtime(&tv);
+	if (tm == NULL)
+		return;
+	fprintf(fp, "%s %04d:%02d:%02d %02d:%02d:%02d\n", TMSTR,
+			tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
+			tm->tm_hour, tm->tm_min, tm->tm_sec);
+}
+
+
+void
+fputnow(fp)			/* write out the current time */
+FILE	*fp;
+{
+	time_t	tv;
+	time(&tv);
+	fputdate(tv, fp);
+}
+
+
+void
+printargs(ac, av, fp)		/* print arguments to a file */
+int  ac;
+char  **av;
+FILE  *fp;
+{
+	int  quote;
+
+	while (ac-- > 0) {
+//WARN HACK		fputword(*av++, fp);
+		fputc(ac ? ' ' : '\n', fp);
+	}
+}
+
+
+int
+formatval(r, s)			/* get format value (return true if format) */
+register char  *r;
+register char  *s;
+{
+	register char  *cp = FMTSTR;
+
+	while (*cp) if (*cp++ != *s++) return(0);
+	while (isspace(*s)) s++;
+	if (!*s) return(0);
+	if (r == NULL) return(1);
+	do
+		*r++ = *s++;
+	while(*s && !isspace(*s));
+	*r = '\0';
+	return(1);
+}
+
+
+int
+isformat(s)			/* is line a format line? */
+char  *s;
+{
+	return(formatval(NULL, s));
+}
+
+
+void
+fputformat(s, fp)		/* put out a format value */
+char  *s;
+FILE  *fp;
+{
+	fputs(FMTSTR, fp);
+	fputs(s, fp);
+	putc('\n', fp);
+}
+
+
+int
+getheader(fp, f, p)		/* get header from file */
+FILE  *fp;
+int  (*f)();
+char  *p;
+{
+	char  buf[MAXLINE];
+
+	for ( ; ; ) {
+		buf[MAXLINE-2] = '\n';
+		if (fgets(buf, MAXLINE, fp) == NULL)
+			return(-1);
+		if (buf[0] == '\n')
+			return(0);
+#ifdef MSDOS
+		if (buf[0] == '\r' && buf[1] == '\n')
+			return(0);
+#endif
+		if (buf[MAXLINE-2] != '\n') {
+			ungetc(buf[MAXLINE-2], fp);	/* prevent false end */
+			buf[MAXLINE-2] = '\0';
+		}
+		if (f != NULL && (*f)(buf, p) < 0)
+			return(-1);
+	}
+}
+
+
+struct check {
+	FILE	*fp;
+	char	fs[64];
+};
+
+
+static int
+mycheck(s, cp)			/* check a header line for format info. */
+char  *s;
+register struct check  *cp;
+{
+	if (!formatval(cp->fs, s) && cp->fp != NULL)
+		fputs(s, cp->fp);
+	return(0);
+}
+
+
+int
+globmatch(p, s)			/* check for match of s against pattern p */
+register char	*p, *s;
+{
+	int	setmatch;
+
+	do {
+		switch (*p) {
+		case '?':			/* match any character */
+			if (!*s++)
+				return(0);
+			break;
+		case '*':			/* match any string */
+			while (p[1] == '*') p++;
+			do
+				if ( (p[1]=='?' || p[1]==*s) &&
+						globmatch(p+1,s) )
+					return(1);
+			while (*s++);
+			return(0);
+		case '[':			/* character set */
+			setmatch = *s == *++p;
+			if (!*p)
+				return(0);
+			while (*++p != ']') {
+				if (!*p)
+					return(0);
+				if (*p == '-') {
+					setmatch += p[-1] <= *s && *s <= p[1];
+					if (!*++p)
+						break;
+				} else
+					setmatch += *p == *s;
+			}
+			if (!setmatch)
+				return(0);
+			s++;
+			break;
+		case '\\':			/* literal next */
+			p++;
+		/* fall through */
+		default:			/* normal character */
+			if (*p != *s)
+				return(0);
+			s++;
+			break;
+		}
+	} while (*p++);
+	return(1);
+}
+
+
+/*
+ * Checkheader(fin,fmt,fout) returns a value of 1 if the input format
+ * matches the specification in fmt, 0 if no input format was found,
+ * and -1 if the input format does not match or there is an
+ * error reading the header.  If fmt is empty, then -1 is returned
+ * if any input format is found (or there is an error), and 0 otherwise.
+ * If fmt contains any '*' or '?' characters, then checkheader
+ * does wildcard expansion and copies a matching result into fmt.
+ * Be sure that fmt is big enough to hold the match in such cases,
+ * and that it is not a static, read-only string!
+ * The input header (minus any format lines) is copied to fout
+ * if fout is not NULL.
+ */
+
+int
+checkheader(fin, fmt, fout)
+FILE  *fin;
+char  *fmt;
+FILE  *fout;
+{
+	struct check	cdat;
+	register char	*cp;
+
+	cdat.fp = fout;
+	cdat.fs[0] = '\0';
+	if (getheader(fin, mycheck, &cdat) < 0)
+		return(-1);
+	if (!cdat.fs[0])
+		return(0);
+	for (cp = fmt; *cp; cp++)		/* check for globbing */
+		if (*cp == '?' | *cp == '*')
+			if (globmatch(fmt, cdat.fs)) {
+				strcpy(fmt, cdat.fs);
+				return(1);
+			} else
+				return(-1);
+	return(strcmp(fmt, cdat.fs) ? -1 : 1);	/* literal match */
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/VRMRun.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/VRMRun.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/VRMRun.cpp	(revision 126)
@@ -0,0 +1,22 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "PreComputingRun.h"
+
+#include "VRMRun.h"
+
+VRMRun::VRMRun(Entity* entity, unsigned int width, unsigned int height)
+{
+	this->entity = entity;
+}
+
+void VRMRun::update()
+{
+}
+
+const String& VRMRun::getResultTextureName()
+{
+	return "VRMRenderingTexture";
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/CAURenderPhotonHitMapPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/CAURenderPhotonHitMapPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/CAURenderPhotonHitMapPass.cpp	(revision 126)
@@ -0,0 +1,35 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "CAURenderPhotonHitMapPass.h"
+
+CAURenderPhotonHitMapPass::CAURenderPhotonHitMapPass( 
+	Root* mRoot):ManagedOgreRenderTexturePass(mRoot,"NO_RENDER_TARGET",1,1)
+{
+	effectWrapper->createMaterial("RenderPhotonHit");
+}
+
+void CAURenderPhotonHitMapPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetFragmentProgramParameters();
+	effectWrapper->SetFloat("g_fPower",g_fPower);
+}
+
+
+void CAURenderPhotonHitMapPass::onRenderEnd(NameValuePairList* namedParams)
+{
+	effectWrapper->EndPass();
+}
+
+float CAURenderPhotonHitMapPass::getPower()
+{
+	return g_fPower;
+}
+
+void CAURenderPhotonHitMapPass::setPower( float f )
+{
+	g_fPower = f;
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/CAURenderRefractObjectMapPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/CAURenderRefractObjectMapPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/CAURenderRefractObjectMapPass.cpp	(revision 126)
@@ -0,0 +1,70 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "CAURenderRefractObjectMapPass.h"
+
+
+CAURenderRefractObjectMapPass::CAURenderRefractObjectMapPass(
+			Root* mRoot):ManagedOgreRenderTexturePass(mRoot,"NO_RENDER_TEXTURE",1,1)
+{
+	effectWrapper->createMaterial("RenderRefractObj");
+}
+
+void CAURenderRefractObjectMapPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetVertexProgramParameters();
+	effectWrapper->SetMatrix("g_mWorldViewProj",g_mWorldViewProj);
+	effectWrapper->SetMatrix("g_mWorldEntityMesh",g_mWorldEntityMesh);
+	effectWrapper->SetVector3("g_vCameraPos3f",g_vCameraPos3f);
+	effectWrapper->SetFragmentProgramParameters();
+	effectWrapper->SetFloat("g_fFovCamera", g_fFovCamera);
+}
+
+
+void CAURenderRefractObjectMapPass::onRenderEnd(NameValuePairList* namedParams)
+{
+	effectWrapper->EndPass();
+}
+
+Matrix4 CAURenderRefractObjectMapPass::getWorldEntityMesh()
+{
+	return g_mWorldEntityMesh;
+}
+
+void CAURenderRefractObjectMapPass::setWorldEntityMesh( Matrix4 matrix4 )
+{
+	g_mWorldEntityMesh = matrix4;
+}
+
+Matrix4 CAURenderRefractObjectMapPass::getWorldViewProj()
+{
+	return g_mWorldViewProj;
+}
+
+void CAURenderRefractObjectMapPass::setWorldViewProj( Matrix4 matrix4 )
+{
+	g_mWorldViewProj = matrix4;
+}
+
+Vector3 CAURenderRefractObjectMapPass::getCameraPos3f()
+{
+	return g_vCameraPos3f;
+}
+
+void CAURenderRefractObjectMapPass::setCameraPos3f( Vector3 v )
+{
+	g_vCameraPos3f = v;
+}
+
+float CAURenderRefractObjectMapPass::getFovCamera()
+{
+	return g_fFovCamera;
+}
+
+void CAURenderRefractObjectMapPass::setFovCamera( float f )
+{
+	g_fFovCamera = f;
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/DiffuseEnvironmentMapRun.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/DiffuseEnvironmentMapRun.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/DiffuseEnvironmentMapRun.cpp	(revision 126)
@@ -0,0 +1,37 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "managedogrerendertexturepass.h"
+#include "DiffuseEnvironmentMapRun.h"
+
+DiffuseEnvironmentMapRun::DiffuseEnvironmentMapRun(Entity* entity, unsigned int resolution)
+{
+	Root* mRoot=Root::getSingletonPtr();
+	OgreAssert(mRoot!=NULL,"Root is not yet generated, rendering will fail.");
+	envMapPass=new DEMEnvironmentMapPass(mRoot,resolution,resolution);
+}
+
+DiffuseEnvironmentMapRun::~DiffuseEnvironmentMapRun(void)
+{
+	delete envMapPass;
+}
+
+void DiffuseEnvironmentMapRun::update(){
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_POSITIVE_X);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_POSITIVE_Y);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_POSITIVE_Z);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_NEGATIVE_X);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_NEGATIVE_Y);
+	envMapPass->update();
+	envMapPass->clearRenderTargets();
+	envMapPass->addRenderTarget(envMapPass->getRenderTexture(),CUBEMAP_FACE_NEGATIVE_Z);
+	envMapPass->update();
+}
Index: trunk/BUTE/Ogre/PreComputingRuns/VRMFilteringMapPass.cpp
===================================================================
--- trunk/BUTE/Ogre/PreComputingRuns/VRMFilteringMapPass.cpp	(revision 126)
+++ trunk/BUTE/Ogre/PreComputingRuns/VRMFilteringMapPass.cpp	(revision 126)
@@ -0,0 +1,71 @@
+//	author:	Barnabas Aszodi (BME-IIT)
+
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "VRMFilteringMapPass.h"
+
+VRMFilteringMapPass::VRMFilteringMapPass(
+			Root* mRoot,const String& renderTextureName,unsigned int width,unsigned int height,
+		 	TextureType texType, PixelFormat internalFormat,
+			const NameValuePairList *miscParams,
+			bool fullScreenQuadRenderer):ManagedOgreRenderTexturePass(mRoot,renderTextureName,width,height,texType,internalFormat,miscParams,fullScreenQuadRenderer)
+{
+	effectWrapper->createMaterial("RenderGeometryTexture");
+	numberOfSamples = 8;
+}
+
+void VRMFilteringMapPass::onRenderStart(NameValuePairList* namedParams){
+	effectWrapper->SetTechniqueToUse(0);
+	effectWrapper->BeginPass();
+	effectWrapper->SetVertexProgramParameters();
+	effectWrapper->SetMatrix("g_mLightViewTexBias",g_mLightViewTexBias);
+	effectWrapper->SetMatrix("g_mWorldViewProj",g_mWorldViewProj);
+	effectWrapper->SetFloatArray("g_vLightPos3f",g_vLightPos3f,3);
+}
+
+
+void VRMFilteringMapPass::onRenderEnd(NameValuePairList* namedParams)
+{
+	effectWrapper->EndPass();
+}
+
+Matrix4 VRMFilteringMapPass::getLightViewTexBias()
+{
+	return g_mLightViewTexBias;
+}
+
+void VRMFilteringMapPass::setLightViewTexBias( Matrix4 matrix4 )
+{
+	g_mLightViewTexBias = matrix4;
+}
+
+Matrix4 VRMFilteringMapPass::getWorldViewProj()
+{
+	return g_mWorldViewProj;
+}
+
+void VRMFilteringMapPass::setWorldViewProj( Matrix4 matrix4 )
+{
+	g_mWorldViewProj = matrix4;
+}
+
+float* VRMFilteringMapPass::getLightPos3f()
+{
+	return g_vLightPos3f;
+}
+
+void VRMFilteringMapPass::setLightPos3f( float* vector3 )
+{
+	g_vLightPos3f = vector3;
+}
+
+int VRMFilteringMapPass::getnumberOfSamples()
+{
+	return numberOfSamples;
+}
+
+void VRMFilteringMapPass::setLightPos3f( int nos )
+{
+	numberOfSamples = nos;
+}
Index: trunk/BUTE/Ogre/OgreEffectWrapper.cpp
===================================================================
--- trunk/BUTE/Ogre/OgreEffectWrapper.cpp	(revision 124)
+++ trunk/BUTE/Ogre/OgreEffectWrapper.cpp	(revision 124)
@@ -0,0 +1,312 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+
+
+EffectWrapper::EffectWrapper(){
+	numberOfCurrentTechnique=-1;
+	numberOfCurrentPass=-1;
+	fragmentProgramParams=false;
+	vertexProgramParams=false;
+	shadowCasterParams=false;
+	shadowReceiverParams=false;
+	canSetNewTechnique=true;
+	this->material.setNull();
+}
+
+EffectWrapper::EffectWrapper(Material* material){
+	numberOfCurrentTechnique=-1;
+	numberOfCurrentPass=-1;
+	fragmentProgramParams=false;
+	vertexProgramParams=false;
+	shadowCasterParams=false;
+	shadowReceiverParams=false;
+	canSetNewTechnique=true;
+	this->material.bind(material);
+}
+
+
+
+EffectWrapper::~EffectWrapper(){
+
+}
+
+//D3D Effect framework style.
+
+bool EffectWrapper::SetFloat(const String& name, float value){
+	if(validateSet()){
+		return false;
+	}
+	if(vertexProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getVertexProgramParameters()->setNamedConstant(name,value);
+	}
+	if(fragmentProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getFragmentProgramParameters()->setNamedConstant(name,value);
+	}
+	if(shadowCasterParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowCasterVertexProgramParameters()->setNamedConstant(name,value);
+	}
+	if(shadowReceiverParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowReceiverVertexProgramParameters()->setNamedConstant(name,value);
+	}
+	return true;
+}
+
+bool EffectWrapper::SetFloatArray(const String& name,const float* value, size_t count){
+	if(validateSet()){
+		return false;
+	}
+	if(vertexProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getVertexProgramParameters()->setNamedConstant(name,value,count);
+	}
+	if(fragmentProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getFragmentProgramParameters()->setNamedConstant(name,value,count);
+	}
+	if(shadowCasterParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowCasterVertexProgramParameters()->setNamedConstant(name,value,count);
+	}
+	if(shadowReceiverParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowReceiverVertexProgramParameters()->setNamedConstant(name,value,count);
+	}
+	return true;
+}
+
+bool EffectWrapper::SetInt(const String& name, int value){
+	if(validateSet()){
+		return false;
+	}
+	if(vertexProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getVertexProgramParameters()->setNamedConstant(name,value);
+	}
+	if(fragmentProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getFragmentProgramParameters()->setNamedConstant(name,value);
+	}
+	if(shadowCasterParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowCasterVertexProgramParameters()->setNamedConstant(name,value);
+	}
+	if(shadowReceiverParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowReceiverVertexProgramParameters()->setNamedConstant(name,value);
+	}
+	return true;
+}
+
+bool EffectWrapper::SetIntArray(const String& name,const int* value, size_t count){
+	if(validateSet()){
+		return false;
+	}
+	if(vertexProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getVertexProgramParameters()->setNamedConstant(name,value,count);
+	}
+	if(fragmentProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getFragmentProgramParameters()->setNamedConstant(name,value,count);
+	}
+	if(shadowCasterParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowCasterVertexProgramParameters()->setNamedConstant(name,value,count);
+	}
+	if(shadowReceiverParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowReceiverVertexProgramParameters()->setNamedConstant(name,value,count);
+	}
+	return true;
+}
+
+bool EffectWrapper::SetDoubleArray(const String& name, double* value, size_t count){
+	if(validateSet()){
+		return false;
+	}
+	if(vertexProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getVertexProgramParameters()->setNamedConstant(name,value,count);
+	}
+	if(fragmentProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getFragmentProgramParameters()->setNamedConstant(name,value,count);
+	}
+	if(shadowCasterParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowCasterVertexProgramParameters()->setNamedConstant(name,value,count);
+	}
+	if(shadowReceiverParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowReceiverVertexProgramParameters()->setNamedConstant(name,value,count);
+	}
+	return true;
+}
+
+bool EffectWrapper::SetMatrix(const String& name, Matrix4& value){
+	if(validateSet()){
+		return false;
+	}
+	if(vertexProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getVertexProgramParameters()->setNamedConstant(name,value);
+	}
+	if(fragmentProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getFragmentProgramParameters()->setNamedConstant(name,value);
+	}
+	if(shadowCasterParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowCasterVertexProgramParameters()->setNamedConstant(name,value);
+	}
+	if(shadowReceiverParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowReceiverVertexProgramParameters()->setNamedConstant(name,value);
+	}
+	return true;
+}
+
+bool EffectWrapper::SetMatrixArray(const String& name, Matrix4* value, size_t numEntries){
+	if(validateSet()){
+		return false;
+	}
+	if(vertexProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getVertexProgramParameters()->setNamedConstant(name,value,numEntries);
+	}
+	if(fragmentProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getFragmentProgramParameters()->setNamedConstant(name,value,numEntries);
+	}
+	if(shadowCasterParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowCasterVertexProgramParameters()->setNamedConstant(name,value,numEntries);
+	}
+	if(shadowReceiverParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowReceiverVertexProgramParameters()->setNamedConstant(name,value,numEntries);
+	}
+	return true;
+}
+
+bool EffectWrapper::SetMatrixTranspose(const String& name, Matrix4& value){
+	if(validateSet()){
+		return false;
+	}
+	Matrix4 transposeValue=value;
+	transposeValue.transpose();
+	if(vertexProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getVertexProgramParameters()->setNamedConstant(name,transposeValue);
+	}
+	if(fragmentProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getFragmentProgramParameters()->setNamedConstant(name,transposeValue);
+	}
+	if(shadowCasterParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowCasterVertexProgramParameters()->setNamedConstant(name,transposeValue);
+	}
+	if(shadowReceiverParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowReceiverVertexProgramParameters()->setNamedConstant(name,transposeValue);
+	}
+	return true;
+}
+
+bool EffectWrapper::SetMatrixTransposeArray(const String& name, Matrix4* value, size_t numEntries){
+	if(validateSet()){
+		return false;
+	}
+	Matrix4* transposeValues=new Matrix4[numEntries];
+	for(unsigned int i=0;i<numEntries;i++){
+		transposeValues[i]=value[i];
+		transposeValues[i].transpose();
+	}
+	if(vertexProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getVertexProgramParameters()->setNamedConstant(name,transposeValues,numEntries);
+	}
+	if(fragmentProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getFragmentProgramParameters()->setNamedConstant(name,transposeValues,numEntries);
+	}
+	if(shadowCasterParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowCasterVertexProgramParameters()->setNamedConstant(name,transposeValues,numEntries);
+	}
+	if(shadowReceiverParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowReceiverVertexProgramParameters()->setNamedConstant(name,transposeValues,numEntries);
+	}
+	delete[] transposeValues;
+	return true;
+}
+
+bool EffectWrapper::SetTexture(int textureUnit,const String& textureName){
+	material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->createTextureUnitState()->setTextureName(textureName);
+	return(true);
+}
+
+//Ogre style.
+
+bool EffectWrapper::SetVector4(const String& name,const Vector4 &vec){
+	if(validateSet()){
+		return false;
+	}
+	if(vertexProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getVertexProgramParameters()->setNamedConstant(name,vec);
+	}
+	if(fragmentProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getFragmentProgramParameters()->setNamedConstant(name,vec);
+	}
+	if(shadowCasterParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowCasterVertexProgramParameters()->setNamedConstant(name,vec);
+	}
+	if(shadowReceiverParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowReceiverVertexProgramParameters()->setNamedConstant(name,vec);
+	}
+	return true;
+}
+
+bool EffectWrapper::SetVector3(const String& name,const Vector3 &vec){
+	if(validateSet()){
+		return false;
+	}
+	if(vertexProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getVertexProgramParameters()->setNamedConstant(name,vec);
+	}
+	if(fragmentProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getFragmentProgramParameters()->setNamedConstant(name,vec);
+	}
+	if(shadowCasterParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowCasterVertexProgramParameters()->setNamedConstant(name,vec);
+	}
+	if(shadowReceiverParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowReceiverVertexProgramParameters()->setNamedConstant(name,vec);
+	}
+	return(true);
+}
+
+bool EffectWrapper::SetReal(const String& name, Real value){
+	if(validateSet()){
+		return false;
+	}
+	if(vertexProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getVertexProgramParameters()->setNamedConstant(name,value);
+	}
+	if(fragmentProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getFragmentProgramParameters()->setNamedConstant(name,value);
+	}
+	if(shadowCasterParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowCasterVertexProgramParameters()->setNamedConstant(name,value);
+	}
+	if(shadowReceiverParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowReceiverVertexProgramParameters()->setNamedConstant(name,value);
+	}
+	return(true);
+}
+
+bool EffectWrapper::SetColourValue(const String& name, const ColourValue &colour){
+	if(validateSet()){
+		return false;
+	}
+	if(vertexProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getVertexProgramParameters()->setNamedConstant(name,colour);
+	}
+	if(fragmentProgramParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getFragmentProgramParameters()->setNamedConstant(name,colour);
+	}
+	if(shadowCasterParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowCasterVertexProgramParameters()->setNamedConstant(name,colour);
+	}
+	if(shadowReceiverParams){
+		material->getTechnique(numberOfCurrentTechnique)->getPass(numberOfCurrentPass)->getShadowReceiverVertexProgramParameters()->setNamedConstant(name,colour);
+	}
+	return(true);
+}
+
+bool EffectWrapper::SetTechniqueToUse(int numberOfTechnique){
+	if(canSetNewTechnique){
+		if(GetNumTechniques()>numberOfTechnique){
+			this->numberOfCurrentTechnique=numberOfTechnique;
+			return true;
+		}
+		else{
+			return false;
+		}
+	}
+	return false;
+}
+
+MaterialPtr& EffectWrapper::getMaterial(){
+	return material;
+}
Index: trunk/BUTE/Ogre/FinalRenderingRun.cpp
===================================================================
--- trunk/BUTE/Ogre/FinalRenderingRun.cpp	(revision 124)
+++ trunk/BUTE/Ogre/FinalRenderingRun.cpp	(revision 124)
@@ -0,0 +1,5 @@
+#include "Ogre.h"
+#include "OgreEffectWrapper.h"
+#include "ManagedOgreRenderTexturePass.h"
+#include "finalrenderingrun.h"
+
