 	bool high, int num_forward, int num_binary
 ) {
 	vec3 step = (1.0 / float(num_forward + 1)) * (b - a);
-	Surface result;
 
 	for (int i = 0; i < num_forward; ++i) {
 		vec3 c = a + step;
 		Surface suf = get_surface(c.xy);
 
 		float height = mix(suf.low_alt, suf.high_alt, high);
-		if (c.z < height) {
-			result = suf;
+		if (c.z <= height) {
 			b = c;
 			break;
 		} else {

		}
	}

	for (int i = 0; i < num_binary; ++i) {
		vec3 c = mix(a, b, 0.5);
		Surface suf = get_surface(c.xy);

		float height = mix(suf.low_alt, suf.high_alt, high);
		if (c.z < height) {
			result = suf;
			b = c;
		} else {
			a = c;
		}

		vec3 outside = cast_ray_to_plane(u_TextureScale.z, a, light_vec);
		vec3 b = outside;

		cast_ray_impl(a, b, true, 4, 4);
		lit_factor = b == outside ? 1.0 : 0.5;
	}

