 
 // GGX microfacet distribution
 // https://www.cs.cornell.edu/~srm/publications/EGSR07-btdf.html
+// This implementation is based on https://bruop.github.io/ibl/ and https://www.tobias-franke.eu/log/2014/03/30/notes_on_importance_sampling.html
 MicrofacetDistributionSample GGX(vec2 xi, float roughness)
 {
     MicrofacetDistributionSample ggx;

    // Typically you'd have the following:
    // float pdf = D_GGX(NoH, roughness) * NoH / (4.0 * VoH);
    // but since V = N => VoH == NoH
    ggx.probability  = D_GGX(ggx.cosTheta, roughness) / 4.0 + 0.001;

    return ggx;
}

        cosTheta = ggx.cosTheta;
        sinTheta = ggx.sinTheta;
        phi = ggx.phi;
        pdf = ggx.pdf;
    }
    else if(u_distribution == cCharlie)
    {
