Refactor NEE& MIS
- NEE = Next Event Estimation;
- MIS = Multiple Importance Sampling.
Currently, our pipeline with NEE works like:
At each bounce: sampleBSDFdirection evaluateDirectLighting(light_dir) if(MIS) evaluateDirectLighting(bsdf_dir) propagateRay(bsdf_direction)
evaluateDirectLighting(out_dir): if(light_pdf(out_dir) <= 0) return // -> light_pdf = 0 if no intersection between the light and the direction. shadowRay(out_dir) if(not_in_shadow) return BSDF_value*mis_weight
When NEE is active, light source emission is disabled so than light are not counted on impact as there are theoretically already accounted for. However, our current implementation sample uniformly one light source per bounce but deactivate ALL sources, even if current point is in shadow, which is a problem. Also, light sampling is currently uniform. It would probably be more efficient to use a light power-based distribution for the sampling.
Finally, I am not sure that the direct evalutation for the BSDF direction is useful as we propagate the ray with this direction in any case. Thus, we may have an extra shadow ray that seems useless.