     vec4 currentColor = texture2D(gm_BaseTexture, v_Texcoord);
     float currentObstacle = texture2D(uObstacles, v_Texcoord).r;
     
-    vec2 offsets[4];
+    vec2 offsets[8];
         offsets[0] = vec2(-1.0,  0.0);
         offsets[1] = vec2(+1.0,  0.0);
         offsets[2] = vec2( 0.0, -1.0);
         offsets[3] = vec2( 0.0, +1.0);
         
-    vec4 colors[4];
+        offsets[4] = vec2(-1.0, -1.0);
+        offsets[5] = vec2(+1.0, +1.0);
+        offsets[6] = vec2(+1.0, -1.0);
+        offsets[7] = vec2(-1.0, +1.0);
+        
+    vec4 colors[8];
         colors[0] = texture2D(gm_BaseTexture, v_Texcoord + uCellSize * offsets[0]);
         colors[1] = texture2D(gm_BaseTexture, v_Texcoord + uCellSize * offsets[1]);
         colors[2] = texture2D(gm_BaseTexture, v_Texcoord + uCellSize * offsets[2]);
         colors[3] = texture2D(gm_BaseTexture, v_Texcoord + uCellSize * offsets[3]);
+        
+        colors[4] = texture2D(gm_BaseTexture, v_Texcoord + uCellSize * offsets[4]);
+        colors[5] = texture2D(gm_BaseTexture, v_Texcoord + uCellSize * offsets[5]);
+        colors[6] = texture2D(gm_BaseTexture, v_Texcoord + uCellSize * offsets[6]);
+        colors[7] = texture2D(gm_BaseTexture, v_Texcoord + uCellSize * offsets[7]);
         
     //Is an obstacle
     if(currentObstacle != 0.0) {

        gl_FragColor = currentColor;
        return;
    }
        
    float obstacles[4]; 
        obstacles[0] = texture2D(uObstacles, v_Texcoord + uCellSize * offsets[0]).r * obstacleHeight;
        obstacles[1] = texture2D(uObstacles, v_Texcoord + uCellSize * offsets[1]).r * obstacleHeight;
        obstacles[2] = texture2D(uObstacles, v_Texcoord + uCellSize * offsets[2]).r * obstacleHeight;
        obstacles[3] = texture2D(uObstacles, v_Texcoord + uCellSize * offsets[3]).r * obstacleHeight;
    
    float values[4];
        values[0] = unpack(colors[0]) + obstacles[0];
        values[1] = unpack(colors[1]) + obstacles[1];
        values[2] = unpack(colors[2]) + obstacles[2];
        values[3] = unpack(colors[3]) + obstacles[3];
        
    float minValue = maxValue;
        if(colors[0] != uBlankColor && obstacles[0] == 0.0)

            
        if(colors[3] != uBlankColor && obstacles[3] == 0.0)
            minValue = min(values[3], minValue);
            
        if(colors[4] != uBlankColor && obstacles[4] == 0.0)
            minValue = min(values[4], minValue);
            
        if(colors[5] != uBlankColor && obstacles[5] == 0.0)
            minValue = min(values[5], minValue);
            
        if(colors[6] != uBlankColor && obstacles[6] == 0.0)
            minValue = min(values[6], minValue);
            
        if(colors[7] != uBlankColor && obstacles[7] == 0.0)
            minValue = min(values[7], minValue);
    
    gl_FragColor = pack(minValue + 1.0);
}
