                 // not obstructed
 
                 float invShadowDist2 = 1.0 / (shadow_dist*shadow_dist);
-                float contribTerm =  -dot(shadow_isec.xyz, shadow_ray) * invShadowDist2;
-                float probOther = contribTerm * dot(normal, shadow_ray) / M_PI;
-                float intensity = dot(normal, shadow_ray) * contribTerm;
+                float changeOfVarsTerm = -dot(shadow_isec.xyz, shadow_ray) * invShadowDist2;
+                float probOther = changeOfVarsTerm * dot(normal, shadow_ray) / M_PI;
 
                 // multiple importance sampling probabilities of different strategies
                 float probThis = light_sample_area_probability;
+                float intensity = dot(normal, shadow_ray) * changeOfVarsTerm / M_PI; // mystery M_PI
 
                 cur_color += ray_color * light_emission * intensity * weight2(probThis, probOther);
             }
 
-            if (was_diffuse) {
-                ray_color *= 1.0 / M_PI;
-            }
             prev_object = which_object;
         }
     }

    float choice_sample = random_choice_sample;
    int light_object = select_light(light_point, light_sample_area_probability, choice_sample);
    get_emission(light_object, light_emission);

    // ray location on image surface after applying tent filter
    vec2 ccd_pos = get_ccd_pos(gl_FragCoord.xy);

        if (which_object == OBJ_NONE) {
            ray_color = ZERO_VEC3;
        } else {
            vec3 normal = intersection.xyz;
            ray_pos += intersection.w * ray;

            vec3 emission = ZERO_VEC3;
            if (get_emission(which_object, emission)) {
                float changeOfVarsTerm = -dot(normal, ray) / (intersection.w*intersection.w);
                float probThis = changeOfVarsTerm * lastCosineWeight /  M_PI;
                float intensity = 1.0; // TODO: ?
                float probOther = light_sample_area_probability;

