double mdotn = Math.abs(m.dot(n));
double ni = -v.dot(n) >= 0.0 ? n1 : n2;
double nt = -v.dot(n) >= 0.0 ? n2 : n1;
double r = Optics.reflectance(v, n1, n2, m.dot(n) > 0.0 ? m : m.opposite());
boolean reflected = RandomUtil.bernoulli(r, rj);
Vector3 out = reflected ? Optics.reflect(v, m) : Optics.refract(v, n1, n2, m);
double g = microfacets.getShadowingAndMasking(v, out, m, n);
double weight = (mdoti / (ndoti * mdotn)) * g;