     cam_y = cross(cam_x, cam_z);
     cam_pos = -cam_z * cam_dist + camera_target;
 
-    vec3 light_point;
+    vec3 light_point, light_normal;
     float light_sample_area_probability;
     vec3 light_emission;
     float choice_sample = random_choice_sample;
-    int light_object = select_light(light_point, light_sample_area_probability, choice_sample);
+    int light_object = select_light(light_point, light_normal, light_sample_area_probability, choice_sample);
     get_emission(light_object, light_emission);
 
     // ray location on image surface after applying tent filter

            int shadow_object = which_object;
            if (which_object != light_object &&
                inside_object == OBJ_NONE && // no lights inside transparent objects supported
                dot(shadow_ray, normal) > 0.0) {
                shadow_object = find_intersection(ray_pos, shadow_ray, which_object, inside_object, shadow_isec);
            }
            else {

    return which_object;
}

int select_light(out vec3 light_point, out vec3 light_normal, out float sample_prob_density_per_area, inout float x) {
      light_normal = normalize(light_sample);
      light_point = light_normal * light_r;
      sample_prob_density_per_area = 1.0 / (UNIT_SPHERE_AREA*light_r*light_r * float(N_LIGHTS));

      int light_object = OBJ_NONE;
