@Override
    public void bakeSphericalHarmonicsCoefficients() {
        Box boxm = new Box(1, 1, 1);
        Geometry screen = new Geometry("BakeBox", boxm);

        Material mat = new Material(assetManager, "Common/IBLSphH/IBLSphH.j3md");
        mat.setTexture("Texture", envMap);
        mat.setVector2("Resolution", new Vector2f(envMap.getImage().getWidth(), envMap.getImage().getHeight()));
        screen.setMaterial(mat);

        float remapMaxValue = 0;
        Format format = Format.RGBA32F;
        if (!renderManager.getRenderer().getCaps().contains(Caps.FloatColorBufferRGBA)) {
            LOG.warning("Float textures not supported, using RGB8 instead. This may cause accuracy issues.");
            format = Format.RGBA8;
            remapMaxValue = 0.05f;
        }

        if (remapMaxValue > 0) {
            mat.setFloat("RemapMaxValue", remapMaxValue);
        } else {
            mat.clearParam("RemapMaxValue");
        }

        Texture2D shCoefTx[] = { new Texture2D(NUM_SH_COEFFICIENT, 1, 1, format), new Texture2D(NUM_SH_COEFFICIENT, 1, 1, format) };

        FrameBuffer shbaker[] = { new FrameBuffer(NUM_SH_COEFFICIENT, 1, 1), new FrameBuffer(NUM_SH_COEFFICIENT, 1, 1) };
        shbaker[0].setSrgb(false);
        shbaker[0].addColorTarget(FrameBufferTarget.newTarget(shCoefTx[0]));

        shbaker[1].setSrgb(false);
        shbaker[1].addColorTarget(FrameBufferTarget.newTarget(shCoefTx[1]));

        int renderOnT = -1;

        for (int faceId = 0; faceId < 6; faceId++) {
            if (renderOnT != -1) {
                int s = renderOnT;
                renderOnT = renderOnT == 0 ? 1 : 0;
                mat.setTexture("ShCoef", shCoefTx[s]);
            } else {
                renderOnT = 0;
            }

            mat.setInt("FaceId", faceId);

            screen.updateLogicalState(0);
            screen.updateGeometricState();

            renderManager.setCamera(updateAndGetInternalCamera(0, shbaker[renderOnT].getWidth(), shbaker[renderOnT].getHeight(), Vector3f.ZERO, 1, 1000), false);
            renderManager.getRenderer().setFrameBuffer(shbaker[renderOnT]);
            renderManager.renderGeometry(screen);
        }

        ByteBuffer shCoefRaw = BufferUtils.createByteBuffer(NUM_SH_COEFFICIENT * 1 * (shbaker[renderOnT].getColorTarget().getFormat().getBitsPerPixel() / 8));
        renderManager.getRenderer().readFrameBufferWithFormat(shbaker[renderOnT], shCoefRaw, shbaker[renderOnT].getColorTarget().getFormat());
        shCoefRaw.rewind();

        Image img = new Image(format, NUM_SH_COEFFICIENT, 1, shCoefRaw, ColorSpace.Linear);
        ImageRaster imgr = ImageRaster.create(img);

        shCoef = new Vector3f[NUM_SH_COEFFICIENT];
        float weightAccum = 0.0f;

        for (int i = 0; i < shCoef.length; i++) {
            ColorRGBA c = imgr.getPixel(i, 0);
            shCoef[i] = new Vector3f(c.r, c.g, c.b);
            if (weightAccum == 0) weightAccum = c.a;
            else if (weightAccum != c.a) {
                LOG.warning("SH weight is not uniform, this may cause issues.");
            }

        }

        if (remapMaxValue > 0) weightAccum /= remapMaxValue;

        for (int i = 0; i < NUM_SH_COEFFICIENT; ++i) {
            if (remapMaxValue > 0) shCoef[i].divideLocal(remapMaxValue);
            shCoef[i].multLocal(4.0f * FastMath.PI / weightAccum);
        }
        EnvMapUtils.prepareShCoefs(shCoef);
        img.dispose();

    }
Create a new IBL env baker

@param rm
           The render manager used to render the env scene
@param am
           The asset manager used to load the baking shaders
@param format
           The format of the color buffers
@param depthFormat
           The format of the depth buffers
@param env_size
           The size in pixels of the output environment cube map (eg.
           1024)
@param specular_size
           The size in pixels of the output specular cube map (eg. 1024)
jme3-core/src/main/java/com/jme3/environment/baker/IBLGLEnvBakerLight.java