public Color getIrradiance(ShadingState state, Color diffuseReflectance) {
   OrthoNormalBasis onb = state.getBasis();
   Vector3 w = new Vector3();
   Color result = Color.black();
   for (int i = 0; i < samples; i++) {
     float xi = (float) state.getRandom(i, 0, samples);
     float xj = (float) state.getRandom(i, 1, samples);
     float phi = (float) (2 * Math.PI * xi);
     float cosPhi = (float) Math.cos(phi);
     float sinPhi = (float) Math.sin(phi);
     float sinTheta = (float) Math.sqrt(xj);
     float cosTheta = (float) Math.sqrt(1.0f - xj);
     w.x = cosPhi * sinTheta;
     w.y = sinPhi * sinTheta;
     w.z = cosTheta;
     onb.transform(w);
     Ray r = new Ray(state.getPoint(), w);
     r.setMax(maxDist);
     result.add(Color.blend(bright, dark, state.traceShadow(r)));
   }
   return result.mul((float) Math.PI / samples);
 }