             dist = vec3(0,h,0);
          else
             dist = vec3(0,0,h);
+            
          // ----
          // Quick fix to defy perspective correction
          dist *= gl_Position.w;

      	 float swizz = p1_3d.w;
      	 vec4 p1_3d_ = p1_3d;
      	 p1_3d_.w = 1.0;
      	 // Compute the vertex position in the usual fashion.
         gl_Position = MVP * position;
      	 // p0 is the 2D position of the current vertex.
      	 vec2 p0 = gl_Position.xy/gl_Position.w;
      	 // Project p1 and p2 and compute the vectors v1 = p1-p0
      	 // and v2 = p2-p0
      	 p1_3d_ = MVP * p1_3d_;
      	 vec2 v1 = WIN_SCALE*(p1_3d_.xy / p1_3d_.w - p0);
      	 vec4 p2_3d_ = MVP * p2_3d;
      	 vec2 v2 = WIN_SCALE*(p2_3d_.xy / p2_3d_.w - p0);
      	 // Compute 2D area of triangle.
      	 float area2 = abs(v1.x*v2.y - v1.y * v2.x);
         // Compute distance from vertex to line in 2D coords
         float h = area2/length(v1-v2);
         // ---
         // The swizz variable tells us which of the three vertices
         // we are dealing with. The ugly comparisons would not be needed if

      varying vec3 dist;
      void main(void)
      {
        // Undo perspective correction.
      	vec3 dist_vec = dist * gl_FragCoord.w;
      	
        // Compute the shortest distance to the edge
      	float d =min(dist_vec[0],min(dist_vec[1],dist_vec[2]));
      	
      	// Compute line intensity and then fragment color
       	float I = exp2(-2.0*d*d);
       	
       	gl_FragColor = I*WIRE_COL + (1.0 - I)*FILL_COL;
      }
      """
