Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDepthShadowMapRenderingRun.h
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDepthShadowMapRenderingRun.h	(revision 1103)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDepthShadowMapRenderingRun.h	(revision 1120)
@@ -42,5 +42,5 @@
 		@brief returns the depth shadow map texture created by this run
 	*/
-	String getDepthMapTextureName(int i){return names[i];}
+	String getDepthMapTextureName(){return name;}
 	/**
 		@brief Refreshes light camera matrices, called in each update.
@@ -50,9 +50,9 @@
 		@brief retuns the view matrix of the camera from which the depth shadow map was created
 	*/
-	Matrix4 getLightViewMatrix(int i);
+	Matrix4 getLightViewMatrix();
 	/**
 		@brief retuns the concatenation of the view and projection matrices of the camera from which the depth shadow map was created
 	*/
-	Matrix4 getLightViewProjMatrix(int i);
+	Matrix4 getLightViewProjMatrix();
 
 protected:	
@@ -64,5 +64,5 @@
 		@brief pointer to the camera of the lightsource
 	*/
-	Camera* depthMapCameras[2];
+	Camera* depthMapCamera;
 	/**
 		@brief the name of the material to be used when rendering the depth shadow map
@@ -76,9 +76,9 @@
 		@brief the name of the depth shadow map texture that was created by this run
 	*/
-	String names[2];
+	String name;
 	/**
 		@brief a pointer to the depth shadow texture that was created by this run
 	*/
-	Texture* depthMapTextures[2];
+	Texture* depthMapTexture;
 	
 	//inherited
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp	(revision 1103)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp	(revision 1120)
@@ -16,6 +16,6 @@
 	this->light = light;
 	this->sharedRuns = sharedRuns;
-	names[0] = name + "1";	
-	names[1] = name + "2";	
+	this->name = name;	
+	
 	this->materialName = materialName;
 
@@ -25,7 +25,6 @@
 void OgreDepthShadowMapRenderingRun::createDepthMap()
 {
-	for(int i = 0; i < 1; i++)
-	{
-		TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(names[i], 
+	
+		TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name, 
 																			"default",
 																			TEX_TYPE_2D,
@@ -36,13 +35,12 @@
 																			PF_FLOAT16_RGBA,
 																			TU_RENDERTARGET);
-		depthMapTextures[i] = texPtr.getPointer();
-		depthMapCameras[i] = Root::getSingleton()._getCurrentSceneManager()->createCamera(names[i] + "_CAMERA");
+		depthMapTexture = texPtr.getPointer();
+		depthMapCamera = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA");
 		//add viewport to rendertarget
-		HardwarePixelBuffer* hpb = (depthMapTextures[i]->getBuffer()).getPointer();
+		HardwarePixelBuffer* hpb = (depthMapTexture->getBuffer()).getPointer();
 		RenderTarget* rt = hpb->getRenderTarget();
-		Viewport* v = rt->addViewport(depthMapCameras[i]);
+		Viewport* v = rt->addViewport(depthMapCamera);
 		v->setOverlaysEnabled(false);
-		rt->setAutoUpdated(false);
-	}
+		rt->setAutoUpdated(false);	
 }
 
@@ -69,6 +67,8 @@
 void OgreDepthShadowMapRenderingRun::updateDepthMap()
 {
-	setMaterialForVisibles(materialName, depthMapCameras[0], false);	
-	RenderTarget* rt = depthMapTextures[0]->getBuffer().getPointer()->getRenderTarget();	
+	setMaterialForVisibles(materialName, depthMapCamera, false);	
+	RenderTarget* rt = depthMapTexture->getBuffer().getPointer()->getRenderTarget();	
+	Viewport* vp = rt->getViewport(0);
+	
 	rt->update();
 	restoreMaterials();
@@ -103,23 +103,28 @@
 			Vector3 lightpos = light->getPosition();
 			Vector3 lightdir = light->getDirection();
+			lightdir.normalise();
+
+			depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC);	
+			/*depthMapCameras[0]->setAspectRatio(1.0);
+			depthMapCameras[0]->setFOVy(Radian(Degree(20)));
+			depthMapCameras[0]->setNearClipDistance(0.1);
+			depthMapCameras[0]->setFarClipDistance(200);*/
+
 			
-			Vector3 center = (min + max) / 2.0;
-			Vector3 scale = max - min;
-			scale.x = 2.0 / scale.x;
-			scale.y = 2.0 / scale.y;
-			scale.z = 2.0 / scale.z;
-			center.x *= scale.x;
-			center.y *= scale.y;
-			center.z *= scale.z;
-
-
-			depthMapCameras[0]->setDirection( lightdir );
-			depthMapCameras[0]->setPosition( lightpos );
-
-			Matrix4 projection = Matrix4::IDENTITY;
-			projection.setTrans(center);
-			projection.setScale(scale);
-			depthMapCameras[0]->setCustomProjectionMatrix(true, projection);	
-/*
+			Vector3 scale = (max - min);
+			scale *= 1.5;
+			//scale = Vector3(150,150,150);
+			Matrix4 projection = depthMapCamera->getProjectionMatrix();
+			projection = Matrix4::IDENTITY;
+			projection.setScale(Vector3(2.0 / scale.x, 2.0 / scale.y, -2.0 / scale.z));			
+			projection.setTrans(Vector3(-(max.x + min.x) / scale.x,
+										-(max.y + min.y) / scale.y,
+										-(max.z + min.z) / scale.z));
+			depthMapCamera->setCustomProjectionMatrix(true, projection);
+			
+			depthMapCamera->setPosition(lightpos);
+			depthMapCamera->setDirection(lightdir);
+			
+	/*
 			projection = Matrix4::IDENTITY;
 			projection.setScale(Vector3(1.0 / 100.0, 1.0 / 100.0, -1.0 / 100.0));
@@ -161,12 +166,12 @@
 }
 
-Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix(int i)
+Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix()
 {
-	return depthMapCameras[i]->getViewMatrix();
+	return depthMapCamera->getViewMatrix();
 }
 
-Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix(int i)
+Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix()
 {
-	return depthMapCameras[i]->getProjectionMatrix() * depthMapCameras[i]->getViewMatrix();
+	return depthMapCamera->getProjectionMatrixWithRSDepth() * depthMapCamera->getViewMatrix();
 }
 
Index: /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowRecieverRenderTechnique.cpp
===================================================================
--- /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowRecieverRenderTechnique.cpp	(revision 1103)
+++ /GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowRecieverRenderTechnique.cpp	(revision 1120)
@@ -45,7 +45,5 @@
 		GpuProgramParameters* Vparams = newpass->getVertexProgramParameters().getPointer();
 		Vparams->setNamedAutoConstant("worldViewProj",
-									GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
-		Vparams->setNamedAutoConstant("world",
-									GpuProgramParameters::ACT_WORLD_MATRIX);
+									GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);	
 		GpuProgramParameters* Fparams = newpass->getFragmentProgramParameters().getPointer();
 		
@@ -55,6 +53,7 @@
 		st->setTextureFiltering(TFO_BILINEAR);		
 
-		newpass->setSceneBlending(SBT_MODULATE);
-		newpass->setDepthBias(7);
+		//newpass->setSceneBlending(SBT_MODULATE);
+		newpass->setSceneBlending(SBF_ONE, SBF_ZERO);
+		newpass->setDepthBias(1);
 		techn->movePass(lastpass, index);			
 	}
@@ -95,14 +94,12 @@
 					
 			passes.at(i)->getTextureUnitState(0)->setTextureName(
-				depthRun->getDepthMapTextureName(0));
-			passes.at(i)->getTextureUnitState(1)->setTextureName(
-				depthRun->getDepthMapTextureName(1));
-
+				depthRun->getDepthMapTextureName());
+		
 			//TODO: set matrices
 			GpuProgramParametersSharedPtr fpParams = passes.at(i)->getFragmentProgramParameters();
-			fpParams->setNamedConstant("lightView", depthRun->getLightViewMatrix(0)); 
-			fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix(0)); 
-		//	fpParams->setNamedConstant("lightView2", depthRun->getLightViewMatrix(1)); 
-		//	fpParams->setNamedConstant("lightViewProj2", depthRun->getLightViewProjMatrix(1)); 
+			GpuProgramParametersSharedPtr vpParams = passes.at(i)->getVertexProgramParameters();
+		
+			//fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix()); 
+			vpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix());
 			
 			passes.at(i)->setActive(true);
