Index: Myth2Code/hardware/OpenGL/render_opengl.c
===================================================================
--- Myth2Code/hardware/OpenGL/render_opengl.c	(revision 4231)
+++ Myth2Code/hardware/OpenGL/render_opengl.c	(working copy)
@@ -178,6 +178,10 @@
 	SetUV(_v, _u0, _v0); \
 	/* NOTE: For the fixed-function path, this also sets color. */ \
 	render_verts[_v]._64bits = current_tint_shader._64bits; }
+#define SetTintDepth(_v, _x, _y, _z, _w, _u0, _v0) { \
+	SetXYZW(_v, _x, _y, _z, _w); \
+	SetUV(_v, _u0, _v0); \
+	render_verts[_v]._64bits = current_tint_shader._64bits; }
 
 /************************************************************************************/
 /* prototypes																		*/
@@ -632,7 +636,7 @@
 	{0, 0, 1, 0, 0, 0}, // _shader_basic_color
 	{1, 0, 1, 0, 0, 0}, // _shader_basic_texture
 	{1, 1, 0, 0, 1, 0}, // _shader_world_texture
-	{1, 1, 0, 0, 1, 1}, // _shader_sprite
+	{1, 1, 0, 1, 1, 1}, // _shader_sprite
 	{0, 1, 0, 1, 0, 0}, // _shader_depth
 	{1, 1, 0, 0, 0, 0}, // _shader_mesh_0
 	{2, 1, 0, 0, 0, 0}, // _shader_mesh_1
@@ -1905,10 +1909,8 @@
 	}
 
 	fclose(fp);
-}
-*/
+}*/
 
-
 static void rasterize_scene_chunked(
 	struct view_data *view,
 	struct render_surface_list *surfaces)
@@ -1922,14 +1924,14 @@
 	rasterize_opaque_category(_surface_category_opaque_objects);
 	rasterize_mesh_category(_surface_category_mesh);
 
-	// Render "Myth-Z" to the depthbuffer.
+	/* // Render "Myth-Z" to the depthbuffer.
 	nvtx_begin("myth-Z pass");
 	glClear(GL_DEPTH_BUFFER_BIT);
 	glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
 	rasterize_depth_category(_surface_category_opaque_objects);
 	rasterize_depth_category(_surface_category_mesh);
 	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
-	nvtx_end();
+	nvtx_end();*/
 
 	// Render 2D objects + translucent surfaces, depth testing against Myth-Z.
 	rasterize_translucent_category(view, _surface_category_translucent_objects);
@@ -2302,10 +2304,33 @@
 		GLtexcoord v0t = v_start + v0*v_scale;
 		GLtexcoord v1t = v_start + v1*v_scale;
 
-		SetTint(0, l, t, z, u0t, v0t);
-		SetTint(1, l, b, z, u0t, v1t);
-		SetTint(2, r, b, z, u1t, v1t);
-		SetTint(3, r, t, z, u1t, v0t);
+		GLposition d0 = z, d1 = d0;
+
+		GLposition l1=l, r1=r,t1=t;
+
+		if(key_down(_key_space))
+		{
+			const int min_z = -((MINIMUM_NEAR_DISTANCE)*WORLD_ONE);
+			short up_y = view->world_to_viewer_rotation.n[2][1];
+			short up_z = view->world_to_viewer_rotation.n[2][2];
+			short ny,nz;
+			float scale;
+			int tmp;
+			ny = up_z, nz = -up_y;
+			scale = (float)(b*nz+z*ny)/(t*nz+z*ny);
+			tmp = d0*scale;
+			d1 = MIN(min_z,tmp);
+			l1 = l*scale;
+			r1 = r*scale;
+			t1 = t*scale;
+			//u0t=v0t=u1t=v1t = 0.5;
+		}
+
+		//u0t=v0t=u1t=v1t = 0.5;
+		SetTintDepth(0, l1, t1, d1, d1, u0t, v0t);
+		SetTintDepth(1, l, b, z, d0, u0t, v1t);
+		SetTintDepth(2, r, b, z, d0, u1t, v1t);
+		SetTintDepth(3, r1, t1, d1, d1, u1t, v0t);
 	}
 
 	set_render_mode_opengl(_shader_sprite, _projection_mode_perspective, rectangle_depth_mode, _blend_mode_premultiplied_alpha);
