private TextureCubeMap generatePrefilteredEnvMap(TextureCubeMap sourceEnvMap, int targetMapSize, EnvMapUtils.FixSeamsMethod fixSeamsMethod, TextureCubeMap store) {
        try {
            TextureCubeMap pem = store;

            int nbMipMap = store.getImage().getMipMapSizes().length;

            setEnd(nbMipMap);

            if (!sourceEnvMap.getImage().hasMipmaps() || sourceEnvMap.getImage().getMipMapSizes().length < nbMipMap) {
                throw new IllegalArgumentException("The input cube map must have at least " + nbMipMap + "mip maps");
            }

            CubeMapWrapper sourceWrapper = new CubeMapWrapper(sourceEnvMap);
            CubeMapWrapper targetWrapper = new CubeMapWrapper(pem);

            Vector3f texelVect = new Vector3f();
            Vector3f color = new Vector3f();
            ColorRGBA outColor = new ColorRGBA();
            int targetMipMapSize = targetMapSize;
            for (int mipLevel = 0; mipLevel < nbMipMap; mipLevel++) {
                float roughness = getRoughnessFromMip(mipLevel, nbMipMap);
                int nbSamples = getSampleFromMip(mipLevel, nbMipMap);

                for (int y = 0; y < targetMipMapSize; y++) {
                    for (int x = 0; x < targetMipMapSize; x++) {
                        color.set(0, 0, 0);
                        getVectorFromCubemapFaceTexCoord(x, y, targetMipMapSize, face, texelVect, fixSeamsMethod);
                        prefilterEnvMapTexel(sourceWrapper, roughness, texelVect, nbSamples, mipLevel, color);

                        outColor.set(Math.max(color.x, 0.0001f), Math.max(color.y, 0.0001f), Math.max(color.z, 0.0001f), 1);
                        targetWrapper.setPixel(x, y, face, mipLevel, outColor);

                    }
                }
                targetMipMapSize /= 2;
                progress();
            }

            return pem;
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
Generates the prefiltered env map (used for image based specular
lighting) With the GGX/Schlick brdf
{@link EnvMapUtils#getSphericalHarmonicsCoefficents(com.jme3.texture.TextureCubeMap)}
Note that the output cube map is in RGBA8 format.

@param sourceEnvMap
@param targetMapSize  the size of the irradiance map to generate
@param store
@param fixSeamsMethod the method to fix seams
@return The irradiance cube map for the given coefficients
jme3-core/src/main/java/com/jme3/environment/generation/PrefilteredEnvMapFaceGenerator.java