public static Vector3f importanceSampleGGX(Vector4f xi, float a2, Vector3f normal, Vector3f store, TempVars vars) {
        if (store == null) {
            store = new Vector3f();
        }

        float cosTheta = sqrt((1f - xi.x) / (1f + (a2 - 1f) * xi.x));
        float sinTheta = sqrt(1f - cosTheta * cosTheta);

        float sinThetaCosPhi = sinTheta * xi.z;//xi.z is cos(phi)
        float sinThetaSinPhi = sinTheta * xi.w;//xi.w is sin(phi)

        Vector3f upVector = Vector3f.UNIT_X;

        if (abs(normal.z) < 0.999) {
            upVector = Vector3f.UNIT_Y;
        }

        Vector3f tangentX = vars.vect3.set(upVector).crossLocal(normal).normalizeLocal();
        Vector3f tangentY = vars.vect4.set(normal).crossLocal(tangentX);

        // Tangent to world space
        tangentX.multLocal(sinThetaCosPhi);
        tangentY.multLocal(sinThetaSinPhi);
        vars.vect5.set(normal).multLocal(cosTheta);

        // Tangent to world space
        store.set(tangentX).addLocal(tangentY).addLocal(vars.vect5);

        return store;
    }
Computes SH coefficient for a given textel dir The method used is the one
from this article : http://graphics.stanford.edu/papers/envmap/envmap.pdf

@param texelVect the input texel (not null, unaffected)
@param shDir storage for the results
jme3-core/src/main/java/com/jme3/environment/util/EnvMapUtils.java