Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp	(revision 1125)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp	(revision 1130)
@@ -17,4 +17,5 @@
 	this->sharedRuns = sharedRuns;
 	this->name = name;	
+	this->blurredname = name + "blurred";
 	
 	this->materialName = materialName;
@@ -34,5 +35,5 @@
 																			0,
 																			PF_FLOAT16_RGBA,
-																			TU_RENDERTARGET);
+																			TU_RENDERTARGET);		
 		depthMapTexture = texPtr.getPointer();
 		depthMapCamera = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA");
@@ -42,5 +43,21 @@
 		Viewport* v = rt->addViewport(depthMapCamera);
 		v->setOverlaysEnabled(false);
-		rt->setAutoUpdated(false);	
+		rt->setAutoUpdated(false);
+
+		texPtr = Ogre::TextureManager::getSingleton().createManual(blurredname, 
+																			"default",
+																			TEX_TYPE_2D,
+																			resolutionX,
+																			resolutionY,
+																			6,
+																			0,
+																			PF_FLOAT16_RGBA,
+																			TU_RENDERTARGET);
+		blurredDepthMapTexture = texPtr.getPointer();
+		hpb = (blurredDepthMapTexture->getBuffer()).getPointer();
+		rt = hpb->getRenderTarget();
+		v = rt->addViewport(depthMapCamera);
+		v->setOverlaysEnabled(false);
+		rt->setAutoUpdated(false);
 }
 
@@ -56,7 +73,5 @@
 	{
 		updateDepthMap();
-	}
-	
-	
+	}	
 }
 
@@ -73,5 +88,14 @@
 	rt->update();
 	restoreMaterials();
-	rt->writeContentsToFile("shadowmap1.dds");
+
+	rt = blurredDepthMapTexture->getBuffer().getPointer()->getRenderTarget();
+	Material*  mat = (Material*) MaterialManager::getSingleton().getByName("GameTools/Blur").getPointer();
+	mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(depthMapTexture->getName());
+	renderFullscreenQuad("GameTools/Blur", rt);
+	
+	
+	//rt->writeContentsToFile("shadowmap1.dds");
+
+	//depthMapTexture->();
 }
 
@@ -118,5 +142,4 @@
 				//left = lightdir.crossProduct(up);
 				left.normalise();				
-
 				Matrix4 viewMatrix( left.x,      left.y,      left.z,		 0,
 									up.x,		 up.y,		  up.z,			 0,
@@ -142,5 +165,4 @@
 
 				Vector3 pos = campos - up * (n - nearclip);
-				
 				Matrix4 newViewMatrix(  left.x,      left.y,      left.z,		 -left.dotProduct(pos),
 										up.x,		 up.y,		  up.z,			 -up.dotProduct(pos),
@@ -148,31 +170,24 @@
 										0,           0,           0,             1);
 
-
-				Matrix4 newProjection = Matrix4::IDENTITY;
-				
-				newProjection[1][1] = (f + n) / (f - n);
-				newProjection[1][3] = - 2* f * n / (f - n);
-				newProjection[3][1] = 1;
-				newProjection[3][3] = 0;
-				//newProjection = newProjection.transpose();
-				Matrix4 standardProjMatrix = Matrix4::IDENTITY;
-				standardProjMatrix.setScale(Vector3(1,1,-1));
-				newProjection = newProjection * standardProjMatrix;
-				depthMapCamera->setCustomProjectionMatrix(true, newProjection);
-				depthMapCamera->setCustomViewMatrix(true, viewMatrix);
+				Matrix4 lispMat = Matrix4::IDENTITY;
+				
+				lispMat[1][1] = f / (f - n);
+				lispMat[1][3] = f * n / (f - n);
+				lispMat[3][1] = 1;
+				lispMat[3][3] = 0;
+				
+				depthMapCamera->setCustomProjectionMatrix(true, Matrix4::IDENTITY);
+				depthMapCamera->setCustomViewMatrix(true, lispMat * newViewMatrix);
 			}
 			else
 			{
-				Matrix4 standardProjMatrix = Matrix4::IDENTITY;
-				standardProjMatrix.setScale(Vector3(0,0,-1));
-				depthMapCamera->setCustomProjectionMatrix(true, standardProjMatrix);
+				depthMapCamera->setCustomProjectionMatrix(true, Matrix4::IDENTITY);
 				depthMapCamera->setCustomViewMatrix(false);
-				depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC);			
 				depthMapCamera->setPosition(lightpos);
-				depthMapCamera->setDirection(lightdir);
+				depthMapCamera->setDirection(lightdir);				
 			}
 
 
-			Matrix4 lightMatrix = depthMapCamera->getProjectionMatrix() * depthMapCamera->getViewMatrix();
+			Matrix4 lightMatrix = depthMapCamera->getViewMatrix();
 			frun->setLightMatrix(lightMatrix);
 			
@@ -191,9 +206,5 @@
 										-(max.y + min.y) / scale.y,
 										-(max.z + min.z) / scale.z));
-			projection = projection * depthMapCamera->getProjectionMatrix();
-			depthMapCamera->setCustomProjectionMatrix(true, projection);
-			
-			
-			
+			depthMapCamera->setCustomProjectionMatrix(true, projection);			
 		}
 		else if(light->getType() == Light::LT_SPOTLIGHT)
