private double[][] getShadowSmoothKernel(int radius) { double res[][] = shadowSmoothKernelMap.get(Integer.valueOf(radius)); if (res == null) { FilterKernel shadowSmoothKernel = new GaussianFilterKernel(); double shadowKernelScale = 1.0; double shadowScaledInvRadius = 1.0 / shadowSmoothRadius * shadowKernelScale * shadowSmoothKernel.getSpatialSupport(); int size = 2 * radius + 1; res = new double[size][size]; for (int k = -radius; k <= radius; k++) { int x = radius + k; double k_square = MathLib.sqr(k * shadowScaledInvRadius); for (int l = -radius; l <= radius; l++) { int y = radius + l; double r = MathLib.sqrt(k_square + MathLib.sqr(l * shadowScaledInvRadius)); res[x][y] = shadowSmoothKernel.getFilterCoeff(r); } } synchronized (shadowSmoothKernelMap) { shadowSmoothKernelMap.put(Integer.valueOf(radius), res); } } return res; }