Search in sources :

Example 6 with Renderer

use of com.jme3.renderer.Renderer in project jmonkeyengine by jMonkeyEngine.

the class AbstractShadowRendererVR method displayShadowMap.

/**
     * For debugging purposes, display depth shadow maps.
     */
protected void displayShadowMap(Renderer r) {
    Camera cam = viewPort.getCamera();
    renderManager.setCamera(cam, true);
    int h = cam.getHeight();
    for (int i = 0; i < dispPic.length; i++) {
        dispPic[i].setPosition((128 * i) + (150 + 64 * (i + 1)), h / 20f);
        dispPic[i].setWidth(128);
        dispPic[i].setHeight(128);
        dispPic[i].updateGeometricState();
        renderManager.renderGeometry(dispPic[i]);
    }
    renderManager.setCamera(cam, false);
}
Also used : Camera(com.jme3.renderer.Camera)

Example 7 with Renderer

use of com.jme3.renderer.Renderer in project jmonkeyengine by jMonkeyEngine.

the class PssmShadowRenderer method postQueue.

@SuppressWarnings("fallthrough")
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 curent split frustra
        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) {
            //                    frustrumFromBound(b.casterBB,ColorRGBA.Blue );
            //                    frustrumFromBound(b.receiverBB,ColorRGBA.Green );
            //                    frustrumFromBound(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
        viewPort.getQueue().renderShadowQueue(splitOccluders, renderManager, shadowCam, true);
    }
    debugfrustums = false;
    //restore setting for future rendering
    r.setFrameBuffer(viewPort.getOutputFrameBuffer());
    renderManager.setForcedMaterial(null);
    renderManager.setForcedTechnique(null);
    renderManager.setCamera(viewCam, false);
}
Also used : Spatial(com.jme3.scene.Spatial) Node(com.jme3.scene.Node) Renderer(com.jme3.renderer.Renderer) Camera(com.jme3.renderer.Camera)

Example 8 with Renderer

use of com.jme3.renderer.Renderer in project jmonkeyengine by jMonkeyEngine.

the class AbstractShadowRenderer method clearMatParams.

private void clearMatParams() {
    for (Material mat : matCache) {
        //at least 1 shadow map and will set it on each frame anyway.
        for (int j = 1; j < nbShadowMaps; j++) {
            mat.clearParam(lightViewStringCache[j]);
        }
        for (int j = 1; j < nbShadowMaps; j++) {
            mat.clearParam(shadowMapStringCache[j]);
        }
        mat.clearParam("FadeInfo");
        clearMaterialParameters(mat);
    }
//No need to clear the postShadowMat params as the instance is locale to each renderer       
}
Also used : Material(com.jme3.material.Material)

Example 9 with Renderer

use of com.jme3.renderer.Renderer in project jmonkeyengine by jMonkeyEngine.

the class AbstractShadowRenderer method postQueue.

@SuppressWarnings("fallthrough")
public void postQueue(RenderQueue rq) {
    lightReceivers.clear();
    skipPostPass = false;
    if (!checkCulling(viewPort.getCamera())) {
        skipPostPass = true;
        return;
    }
    updateShadowCams(viewPort.getCamera());
    Renderer r = renderManager.getRenderer();
    renderManager.setForcedMaterial(preshadowMat);
    renderManager.setForcedTechnique("PreShadow");
    for (int shadowMapIndex = 0; shadowMapIndex < nbShadowMaps; shadowMapIndex++) {
        if (debugfrustums) {
            doDisplayFrustumDebug(shadowMapIndex);
        }
        renderShadowMap(shadowMapIndex);
    }
    debugfrustums = false;
    //restore setting for future rendering
    r.setFrameBuffer(viewPort.getOutputFrameBuffer());
    renderManager.setForcedMaterial(null);
    renderManager.setForcedTechnique(null);
    renderManager.setCamera(viewPort.getCamera(), false);
}
Also used : Renderer(com.jme3.renderer.Renderer)

Example 10 with Renderer

use of com.jme3.renderer.Renderer in project jmonkeyengine by jMonkeyEngine.

the class VRApplication method initCamera.

/**
     * Creates the camera to use for rendering. Default values are perspective
     * projection with 45° field of view, with near and far values 1 and 1000
     * units respectively.
     */
private void initCamera() {
    cam = new Camera(settings.getWidth(), settings.getHeight());
    cam.setFrustumPerspective(45f, (float) cam.getWidth() / cam.getHeight(), 1f, 1000f);
    cam.setLocation(new Vector3f(0f, 0f, 10f));
    cam.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y);
    renderManager = new RenderManager(renderer);
    //Remy - 09/14/2010 setted the timer in the renderManager
    renderManager.setTimer(timer);
    viewPort = renderManager.createMainView("Default", cam);
    viewPort.setClearFlags(true, true, true);
    // Create a new cam for the gui
    Camera guiCam = new Camera(settings.getWidth(), settings.getHeight());
    guiViewPort = renderManager.createPostView("Gui Default", guiCam);
    guiViewPort.setClearFlags(false, false, false);
}
Also used : Vector3f(com.jme3.math.Vector3f) Camera(com.jme3.renderer.Camera) RenderManager(com.jme3.renderer.RenderManager)

Aggregations

Renderer (com.jme3.renderer.Renderer)17 Camera (com.jme3.renderer.Camera)7 Vector3f (com.jme3.math.Vector3f)5 Material (com.jme3.material.Material)4 SceneProcessor (com.jme3.post.SceneProcessor)3 RendererException (com.jme3.renderer.RendererException)3 GLExt (com.jme3.renderer.opengl.GLExt)3 GLFbo (com.jme3.renderer.opengl.GLFbo)3 GLRenderer (com.jme3.renderer.opengl.GLRenderer)3 Uniform (com.jme3.shader.Uniform)3 CartoonSSAO (com.jme3.post.CartoonSSAO)2 Filter (com.jme3.post.Filter)2 FilterPostProcessor (com.jme3.post.FilterPostProcessor)2 HDRRenderer (com.jme3.post.HDRRenderer)2 FogFilter (com.jme3.post.filters.FogFilter)2 TranslucentBucketFilter (com.jme3.post.filters.TranslucentBucketFilter)2 SSAOFilter (com.jme3.post.ssao.SSAOFilter)2 Caps (com.jme3.renderer.Caps)2 RenderManager (com.jme3.renderer.RenderManager)2 LwjglGL (com.jme3.renderer.lwjgl.LwjglGL)2