             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) {
+                dot(shadow_ray, normal) > 0.0 &&
+                dot(shadow_ray, light_normal) < 0.0) {
                 shadow_object = find_intersection(ray_pos, shadow_ray, which_object, inside_object, shadow_isec);
             }
             else {


                // multiple importance sampling probabilities of different strategies
                float probThis = light_sample_area_probability;
                float intensity = dot(normal, shadow_ray) * changeOfVarsTerm / probThis / (2.0 * M_PI); // mystery 2*PI

                cur_color += ray_color * light_emission * intensity * weight2(probThis, probOther);
            }

    cam_y = cross(cam_x, cam_z);
    cam_pos = -cam_z * cam_dist + camera_target;

    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_normal, light_sample_area_probability, choice_sample);
    get_emission(light_object, light_emission);

    // ray location on image surface after applying tent filter
