Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.h
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.h	(revision 2980)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.h	(revision 3126)
@@ -21,9 +21,8 @@
 
 public:
-	/** Constructs a geometry from the given data. 
-		The vertices are interpreted as triangles.
-
-		If delData is true, the vertex / normal / texture is deleted when
-		after it was transferred into a vbo
+	/** Constructs a geometry from the given data. The vertices are 
+		interpreted as triangles. If delData is true, the 
+		vertex / normal / texture is deleted when after it was 
+		transferred into a vbo
 	*/
 	Geometry(Vector3 *vertices, 
@@ -31,19 +30,26 @@
 			 Texcoord2 *texcoords, 
 			 int numVertices, 
-			 bool delData);
-
+			 bool delData,
+			 Vector3 *tangents);
+	/** Detructor destroying the opengl resources.
+	*/
 	~Geometry();
 	/** Render the geometry
 	*/
 	void Render(RenderState *state);
-
-	int GetNumTriangles() const { return mNumVertices / 3; }
-
+	/** Return bounding box.
+	*/
+	const AxisAlignedBox3& GetBoundingBox() const;
+	/** Returns the number of triangles in this geometry.
+	*/
+	inline int GetNumTriangles() const { return mNumVertices / 3; }
+	/** Returns true if this geometry has a texture
+	*/
 	inline bool HasTexture() const { return mHasTexture; }
 	
-	const AxisAlignedBox3& GetBoundingBox() const;
 
 protected:
-
+	/** Calculates the bounding box from the vertices.
+	*/
 	void CalcBoundingBox();
 	/** Prepare vbos for rendering
@@ -58,4 +64,6 @@
 	Vector3 *mNormals;
 
+	Vector3 *mTangents;
+
 	Texcoord2 *mTexCoords;
 
@@ -67,4 +75,6 @@
 
 	bool mHasTexture;
+
+	bool mHasTangents;
 };
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp	(revision 3021)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp	(revision 3126)
@@ -23,12 +23,15 @@
 				   Texcoord2 *texcoords,
 				   int numVertices,
-				   bool delData):
+				   bool delData,
+				   Vector3 *tangents):
 mVertices(vertices), 
 mNormals(normals), 
 mTexCoords(texcoords),
+mTangents(tangents),
 mNumVertices(numVertices), 
 mVboId(-1)
 {
 	mHasTexture = (mTexCoords != NULL);
+	mHasTangents = (mTangents != NULL);
 
 	Prepare();
@@ -39,4 +42,5 @@
 		DEL_ARRAY_PTR(mNormals);
 		DEL_ARRAY_PTR(mTexCoords);
+		DEL_ARRAY_PTR(mTangents);
 	}
 }
@@ -48,4 +52,5 @@
 	DEL_ARRAY_PTR(mNormals);
 	DEL_ARRAY_PTR(mTexCoords);
+	DEL_ARRAY_PTR(mTangents);
 
 	// delete vbo
@@ -60,7 +65,8 @@
 	int dataSize = mNumVertices * 6;
 
-	if (mTexCoords)
-		dataSize += mNumVertices * 2;
+	if (mTexCoords)	dataSize += mNumVertices * 2;
 	
+	if (mTangents) dataSize += mNumVertices * 3;
+
 	float *data = new float[dataSize];
 
@@ -71,25 +77,46 @@
 	}
 
+	float *currentPData = data + mNumVertices * 6;
+
+	if (mTangents)
+	{
+		for (int i = 0; i < mNumVertices; ++ i)
+			((Vector3 *)data)[mNumVertices * 3 + i] = mTangents[i];
+
+		currentPData += mNumVertices * 3;
+	}
+
 	if (mTexCoords)
 	{
 		for (int i = 0; i < mNumVertices; ++ i)
-			((Texcoord2 *)data)[mNumVertices * 3 + i] = mTexCoords[i];
+			((Texcoord2 *)currentPData)[i] = mTexCoords[i];
 	}
+
 
 	glGenBuffersARB(1, &mVboId);
 	glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId);
 
+	int currentPVbo = 0;
+
 	glVertexPointer(3, GL_FLOAT, 0, (char *)NULL);
-	glNormalPointer(GL_FLOAT, 0, (char *)NULL + mNumVertices * sizeof(Vector3));
+
+	currentPVbo += mNumVertices * sizeof(Vector3);
+	glNormalPointer(GL_FLOAT, 0, (char *)NULL + currentPVbo);
+
+	currentPVbo += mNumVertices * 2 * sizeof(Vector3);
+
+	if (mTangents)
+	{
+		glColorPointer(3, GL_FLOAT, 0, (char *)NULL + currentPVbo);
+		currentPVbo += mNumVertices * sizeof(Vector3);
+	}
 
 	if (mTexCoords)
 	{
-		glTexCoordPointer(2, GL_FLOAT, 0, (char *)NULL + 2 * mNumVertices * sizeof(Vector3));
+		glTexCoordPointer(2, GL_FLOAT, 0, (char *)NULL + currentPVbo);
 	}
 
-	glBufferDataARB(GL_ARRAY_BUFFER_ARB, 
-		            dataSize * sizeof(float), 
-		            (float *)data, 
-					GL_STATIC_DRAW_ARB);
+	glBufferDataARB(GL_ARRAY_BUFFER_ARB, dataSize * sizeof(float), 
+		            (float *)data, GL_STATIC_DRAW_ARB);
 
 	glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderManager.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderManager.cpp	(revision 3116)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderManager.cpp	(revision 3126)
@@ -100,5 +100,5 @@
 
 	// add a texture parameter
-	fragmentProgMrtTex->AddParameter("tex", 1);
+	//fragmentProgMrtTex->AddParameter("tex", 1);
 
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg	(revision 3123)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg	(revision 3126)
@@ -124,6 +124,6 @@
 		//ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights);
 		//ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights, 1.0f / (1.0f + ao.y));
-		ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor / (scaleFactor + ao.y));
-		//ao.x = BilateralFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 1.0f);
+		//ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor / (scaleFactor + ao.y));
+		ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 1.0f);
 	}
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg	(revision 3118)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg	(revision 3126)
@@ -75,5 +75,5 @@
 
 pixel fragtex(fragin IN, 
-			  uniform sampler2D tex,
+			  uniform sampler2D tex: TEXUNIT0,
 			  uniform float4x4 viewMatrix
 			  )
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 3117)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp	(revision 3126)
@@ -236,4 +236,20 @@
 
 
+	// set texture for fixed function rendering
+	if (tex)
+	{
+		if (mCurrentTexId != tex->GetId())
+		{
+			tex->Bind();
+			mCurrentTexId = tex->GetId();
+		}
+	}
+	else
+	{
+		mCurrentTexId = -1;
+		glBindTexture(GL_TEXTURE_2D, 0);
+	}
+
+
 	//////////////////
 	//-- fragment and vertex programs
@@ -292,22 +308,4 @@
 		}
 	}
-
-	if (!mFragmentProgramEnabled)
-	{
-		// set texture for fixed function rendering
-		if (tex)
-		{
-			if (mCurrentTexId != tex->GetId())
-			{
-				tex->Bind();
-				mCurrentTexId = tex->GetId();
-			}
-		}
-		else
-		{
-			mCurrentTexId = -1;
-			glBindTexture(GL_TEXTURE_2D, 0);
-		}
-	}
 }
 
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 3115)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp	(revision 3126)
@@ -292,14 +292,9 @@
 
 	if (deferred->GetTexture())
-	{
 		deferred->SetFragmentProgram(sDefaultFragmentTexProgramMrt);
-		deferred->GetFragmentProgramParameters()->SetViewMatrixParam(0);
-		deferred->GetFragmentProgramParameters()->SetTexture(1, tech->GetTexture()->GetId());
-	}	
 	else
-	{
 		deferred->SetFragmentProgram(sDefaultFragmentProgramMrt);
-		deferred->GetFragmentProgramParameters()->SetViewMatrixParam(0);
-	}
+
+	deferred->GetFragmentProgramParameters()->SetViewMatrixParam(0);
 
 	deferred->SetVertexProgram(sDefaultVertexProgramMrt);
@@ -361,5 +356,5 @@
 	}
 
-	return new Geometry(vertices, normals, texcoords, vertexCount, true);
+	return new Geometry(vertices, normals, texcoords, vertexCount, true, NULL);
 	//return new Geometry(vertices, normals, texcoords, vertexCount, false);
 }
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntityConverter.cpp
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntityConverter.cpp	(revision 3071)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntityConverter.cpp	(revision 3126)
@@ -41,5 +41,5 @@
 	cout << "number of triangles in box: " << (int)triangles.size() << endl;
 
-	Geometry *geom = new Geometry(vertices, normals, NULL, 36, false);
+	Geometry *geom = new Geometry(vertices, normals, NULL, 36, false, NULL);
 
 	Shape *shape = new Shape(geom, mat);
Index: GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
===================================================================
--- GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 3110)
+++ GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj	(revision 3126)
@@ -764,4 +764,8 @@
 			</File>
 			<File
+				RelativePath=".\src\shaders\normalMapping.cg"
+				>
+			</File>
+			<File
 				RelativePath=".\src\shaderenv.h"
 				>
