Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPEnvMap/GTPEnvMap.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPEnvMap/GTPEnvMap.hlsl	(revision 2409)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPEnvMap/GTPEnvMap.hlsl	(revision 2471)
@@ -13,5 +13,5 @@
 }
 
-#define SECANT_ITERATIONCOUNT 2
+#define SECANT_ITERATIONCOUNT 20
 
 float3 Hit( float3 x, float3 R, samplerCUBE mp )
@@ -91,4 +91,5 @@
 										uniform float sRefraction ) :COLOR0
 {
+	float4 Color = 0;
 	float3 N = normalize(IN.wNormal.xyz);
 	float3 RR, TT;	
@@ -97,16 +98,25 @@
 	float3 R = reflect( V, N);	
 	float3 T = refract(V, N, sRefraction);
-	
+
+		
 	RR = R;	TT = T; 
 	RR = Hit(cubePos, R, DistanceMap);
-	TT = Hit(cubePos, T, DistanceMap);
+	float4 reflectcolor = readCubeMap(CubeMap, RR );		
 	
-	float4 reflectcolor = readCubeMap(CubeMap, RR );		
-	float4 refractcolor = readCubeMap(CubeMap, TT );		
+	if(dot(T,T)!=0)
+	{
+		TT = Hit(cubePos, T, DistanceMap);
+		float4 refractcolor = readCubeMap(CubeMap, TT );		
 	
-	float cos_theta = -dot(V, N);
-	float F = (sFresnel + pow(1 - cos_theta, 5.0f) * (1 - sFresnel));
-    	
-	return (F * reflectcolor + (1 - F) * refractcolor);	
+		float cos_theta = -dot(V, N);
+		float F = (sFresnel + pow(1 - cos_theta, 5.0f) * (1 - sFresnel));
+    		F = saturate(F);
+		Color =  (F * reflectcolor + (1 - F) * refractcolor);
+	}
+	else
+	{
+		Color = reflectcolor;
+	}
+  return Color;
 }
 
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.material	(revision 2368)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.material	(revision 2471)
@@ -33,5 +33,6 @@
   { 
    cull_hardware none
-   scene_blend src_alpha one
+   scene_blend one one
+   scene_blend_alpha one zero
    depth_check off
    point_sprites on
@@ -65,5 +66,6 @@
   { 
    cull_hardware none
-   scene_blend src_alpha one
+   scene_blend one one
+   scene_blend_alpha one zero
    depth_write off
    vertex_program_ref GTP/Caustic/CauCube_Triangles_VS
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.hlsl	(revision 2368)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.hlsl	(revision 2471)
@@ -62,5 +62,7 @@
 		
 	float3 R = refract(V, wNormal, refIndex);		
-	
+	if(dot(R,R) == 0)
+	  R = reflect(V, wNormal);		
+
 	dir = R;			
 	dir = Hit(cubeMapPos, R, DistanceMap);
@@ -140,5 +142,7 @@
   IN.color = CausticColor;
   float intens = tex2D(intensityTex, IN.texCoord).r;
-  IN.color.a *= intens;
+  //IN.color.a *= intens;
+  IN.color *= IN.color.a * intens;
+  IN.color.a = IN.dist;
   return IN.color;  
 }
@@ -149,5 +153,6 @@
 {
 	float4 hPosition	: POSITION;
-	float4 color		: COLOR0;	
+	float4 color		: COLOR0;
+	float dist		: TEXCOORD0;	
 };
 
@@ -231,5 +236,6 @@
 			OUT.color = float4(1,1,1,1);		
 	}  
-   
+  
+   OUT.dist = length(pos.xyz);
    return OUT;
 }
@@ -238,5 +244,6 @@
 		uniform float4 CausticColor ):COLOR
 { 
-  return IN.color * CausticColor;  
+
+  return float4(IN.color.rgb * CausticColor.rgb * IN.color.a, IN.dist);  
 }
 
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.hlsl
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.hlsl	(revision 2337)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.hlsl	(revision 2471)
@@ -443,2 +443,53 @@
 	return kd * I;
 }
+
+float4 Glossy_Disc2Point_PS(Shaded_OUT IN,
+							uniform float3 lastCenter,
+							uniform float3 cameraPos,
+							uniform samplerCUBE SmallEnvMapSampler : register(s0),
+							uniform samplerCUBE DistanceEnvMapSampler : register(s1)
+		   ) : COLOR0
+{
+	float M = REDUCED_CUBEMAP_SIZE;
+	
+    float3 N = IN.wNormal.xyz;
+    N = normalize( N );
+    float3 V = normalize(IN.wPos.xyz - cameraPos); 
+    float3 pos = IN.wPos.xyz - lastCenter;																		
+    float3 R = reflect( V, N );									
+
+    float rr = max( max(abs(R.x), abs(R.y)), abs(R.z) );	// select the largest component
+    R /= rr;	// scale the largest component to value +/-1
+
+    float3 offset1 = float3(1,0,0);
+    float3 offset2 = float3(0,1,0);
+    if (abs(R.x) > abs(R.y) && abs(R.x) > abs(R.z)) 
+		offset1 = float3(0,0,1);	
+    if (abs(R.y) > abs(R.x) && abs(R.y) > abs(R.z))
+		offset2 = float3(0,0,1);
+
+
+    float4 I = 0;									
+    float3 L;						
+    float width = 2.0 / M;
+    	    
+        L = R;
+	I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler);
+	
+	L = R + offset1 * width;
+	I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler);
+	
+	L = R - offset1 * width;
+	I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler);
+		
+	L = R + offset2 * width;
+	I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler);
+		
+	L = R - offset2 * width;
+	I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler);
+		
+	
+   float kd = 1.0;
+//return readCubeMap(SmallEnvMapSampler, pos) + lastCenter.x*0.0000000001;
+   return kd * I * 2 * M;
+}
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.program
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.program	(revision 2337)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.program	(revision 2471)
@@ -23,4 +23,12 @@
 }  
 
+fragment_program GTP/Glossy/Disc2Point_PS hlsl
+{
+	source GTPDiffuse.hlsl
+	entry_point Glossy_Disc2Point_PS
+	target ps_3_0
+	//flow_control prefer
+}  
+
 fragment_program GTP/Diffuse/ReduceCubeMap_PS hlsl
 {
Index: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.material
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.material	(revision 2445)
+++ GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.material	(revision 2471)
@@ -138,4 +138,59 @@
 material GTP/Diffuse/Disc2Point
 { 
+   technique
+   { 
+      pass
+      { 
+		
+		IllumTechniques
+		{
+			
+			RenderTechnique DistanceCubeMap
+			{
+				update_interval		0
+				update_all_face		true
+				distance_calc		false
+				face_angle_calc		false
+				resolution			128						
+			}
+			RenderTechnique ReducedColorCubeMap
+			{
+				update_interval		1
+				reduced_resolution 4
+				resolution 128
+				distance_calc false
+				face_angle_calc false
+				update_all_face		true
+			}
+		}      
+
+		vertex_program_ref GTP/Basic/Shaded_VS
+		{       
+			param_named_auto WorldViewProj worldviewproj_matrix 
+    		param_named_auto WorldInv      inverse_world_matrix  
+    		param_named_auto World         world_matrix
+        
+		} 
+		fragment_program_ref GTP/Diffuse/Disc2Point_PS
+		{ 
+		    param_named_auto cameraPos camera_position
+			param_named lastCenter float3 0 0 0
+		} 		
+		//Cube map for reflections and refractions	
+		texture_unit
+		{
+			
+		}
+		//Cube map of distances
+		texture_unit
+		 {
+		  
+		 }
+	 }
+   }
+}
+
+material GTP/Glossy/Disc2Point
+{ 
    technique 
    { 
@@ -148,29 +203,29 @@
 			RenderTechnique DistanceCubeMap
 			{
-				update_interval		1
-				update_all_face		false
-				distance_calc		false
-				face_angle_calc		false
-				resolution			128						
-			}
-			RenderTechnique ReducedColorCubeMap
-			{
-				update_interval		1
-				reduced_resolution 4
-				resolution 128
-				distance_calc false
-				face_angle_calc false
-				update_all_face		false
-			}
-		}      
-
-		vertex_program_ref GTP/Basic/Shaded_VS
-		{       
-			param_named_auto WorldViewProj worldviewproj_matrix 
-    		param_named_auto WorldInv      inverse_world_matrix  
-    		param_named_auto World         world_matrix
-        
-		} 
-		fragment_program_ref GTP/Diffuse/Disc2Point_PS
+				update_interval		0
+				update_all_face		true
+				distance_calc		false
+				face_angle_calc		false
+				resolution			128						
+			}
+			RenderTechnique ReducedColorCubeMap
+			{
+				update_interval		1
+				reduced_resolution 4
+				resolution 128
+				distance_calc false
+				face_angle_calc false
+				update_all_face		true
+			}
+		}      
+
+		vertex_program_ref GTP/Basic/Shaded_VS
+		{       
+			param_named_auto WorldViewProj worldviewproj_matrix 
+    		param_named_auto WorldInv      inverse_world_matrix  
+    		param_named_auto World         world_matrix
+        
+		} 
+		fragment_program_ref GTP/Glossy/Disc2Point_PS
 		{ 
 		    param_named_auto cameraPos camera_position
