@SuppressWarnings("fallthrough")
    @Override
    public void postQueue(RenderQueue rq) {
        for (Spatial scene : viewPort.getScenes()) {
            ShadowUtil.getGeometriesInCamFrustum(scene, viewPort.getCamera(), ShadowMode.Receive, lightReceivers);
        }

        Camera viewCam = viewPort.getCamera();

        float zFar = zFarOverride;
        if (zFar == 0) {
            zFar = viewCam.getFrustumFar();
        }

        //We prevent computing the frustum points and splits with zeroed or negative near clip value
        float frustumNear = Math.max(viewCam.getFrustumNear(), 0.001f);
        ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, 1.0f, points);

        //shadowCam.setDirection(direction);
        shadowCam.getRotation().lookAt(direction, shadowCam.getUp());
        shadowCam.update();
        shadowCam.updateViewProjection();

        PssmShadowUtil.updateFrustumSplits(splitsArray, frustumNear, zFar, lambda);


        switch (splitsArray.length) {
            case 5:
                splits.a = splitsArray[4];
            case 4:
                splits.b = splitsArray[3];
            case 3:
                splits.g = splitsArray[2];
            case 2:
            case 1:
                splits.r = splitsArray[1];
                break;
        }

        Renderer r = renderManager.getRenderer();
        renderManager.setForcedMaterial(preshadowMat);
        renderManager.setForcedTechnique("PreShadow");

        for (int i = 0; i < nbSplits; i++) {

            // update frustum points based on current camera and split
            ShadowUtil.updateFrustumPoints(viewCam, splitsArray[i], splitsArray[i + 1], 1.0f, points);

            //Updating shadow cam with current split frusta
            ShadowUtil.updateShadowCamera(viewPort, lightReceivers, shadowCam, points, splitOccluders, shadowMapSize);

            //saving light view projection matrix for this split            
            lightViewProjectionsMatrices[i].set(shadowCam.getViewProjectionMatrix());
            renderManager.setCamera(shadowCam, false);

            if (debugfrustums) {
//                    frustumFromBound(b.casterBB,ColorRGBA.Blue );
//                    frustumFromBound(b.receiverBB,ColorRGBA.Green );
//                    frustumFromBound(b.splitBB,ColorRGBA.Yellow );
                ((Node) viewPort.getScenes().get(0)).attachChild(createFrustum(points, i));
                ShadowUtil.updateFrustumPoints2(shadowCam, points);
                ((Node) viewPort.getScenes().get(0)).attachChild(createFrustum(points, i));

            }

            r.setFrameBuffer(shadowFB[i]);
            r.clearBuffers(true, true, true);

            // render shadow casters to shadow map and disables the lightfilter
            LightFilter tmpLightFilter = renderManager.getLightFilter();
            renderManager.setLightFilter(NULL_LIGHT_FILTER);
            viewPort.getQueue().renderShadowQueue(splitOccluders, renderManager, shadowCam, true);
            renderManager.setLightFilter(tmpLightFilter);
        }
        debugfrustums = false;

        //restore setting for future rendering
        r.setFrameBuffer(viewPort.getOutputFrameBuffer());
        renderManager.setForcedMaterial(null);
        renderManager.setForcedTechnique(null);
        renderManager.setCamera(viewCam, false);

    }
Sets the light direction to use to compute shadows

@param direction a direction vector (not null, unaffected)
jme3-core/src/main/java/com/jme3/shadow/PssmShadowRenderer.java