 
 		// if out of range, stop
 #ifdef BEAMER
-		if(any(lessThan(cell, ivec3(0)))) return atime;
-		if(any(greaterThanEqual(cell<<layer, ivec3(256,512,512)))) return atime;
+		if(any(lessThan(cell, ivec3(0))))
+			return (maxtime == RENDER_MAXTIME ? atime : maxtime);
+		if(any(greaterThanEqual(cell<<layer, ivec3(256,512,512))))
+			return (maxtime == RENDER_MAXTIME ? atime : maxtime);
 #else
 		if(any(lessThan(cell, ivec3(0)))) return maxtime;
 		if(any(greaterThanEqual(cell<<layer, ivec3(256,512,512)))) return maxtime;


	// sunlight + moonlight
	// TODO: adjustable angle + colour
	if(false){
		const vec3 SUNLIGHT = vec3(-1.0, 0.2, 0.2);
		vec3 cast_pos, cast_norm;
		vec4 cast_col;
		cast_pos = outpos - frnorm*0.1;
		float cast_time = cast_ray(cast_pos, SUNLIGHT, cast_norm, RENDER_MAXTIME, cast_col);

		if(cast_time >= RENDER_MAXTIME*0.9)
			diffamb += vec3(0.8, 0.8, 0.8)*max(0.0, -dot(normalize(SUNLIGHT),frnorm));

	}


const int MAX_LAYER = 5;
const float EPSILON = 0.0001;
float RENDER_MAXTIME = 10000.0;

uint world_get_geom(ivec3 pos, int layer)
{
