 			vec2 cone_dir = final_pos - line_begin;
 			float cone_len = length(cone_dir);
 			cone_dir = normalize(cone_dir); //will be used normalized from now on
-			float max_mipmap = filter_mipmap_levels -1;
+			float max_mipmap = filter_mipmap_levels - 1.0;
 			float gloss_mult=gloss;
 
 			float rem_alpha=1.0;


	// clip the line to the viewport edges

	float scale_max_x = min(1, 0.99 * (1.0 - vp_line_begin.x) / max(1e-5, vp_line_dir.x));
	float scale_max_y = min(1, 0.99 * (1.0 - vp_line_begin.y) / max(1e-5, vp_line_dir.y));
	float scale_min_x = min(1, 0.99 * vp_line_begin.x / max(1e-5, -vp_line_dir.x));
	float scale_min_y = min(1, 0.99 * vp_line_begin.y / max(1e-5, -vp_line_dir.y));
	float line_clip = min(scale_max_x, scale_max_y) * min(scale_min_x, scale_min_y);
	line_dir *= line_clip;
	z_dir *= line_clip;


	//if acceleration > 0, distance between pixels gets larger each step. This allows covering a larger area
	float accel=1.0+acceleration;
	float steps_taken=0.0;

	for(int i=0;i<num_steps;i++) {

		pos+=line_advance;
		z+=z_advance;
