Search in sources :

Example 6 with RenderManager

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

the class TestFBOPassthrough method simpleRender.

@Override
public void simpleRender(RenderManager rm) {
    Renderer r = rm.getRenderer();
    //do FBO rendering
    r.setFrameBuffer(fb);
    // FBO uses current camera
    rm.setCamera(cam, false);
    r.clearBuffers(true, true, true);
    rm.renderScene(fbNode, viewPort);
    rm.flushQueue(viewPort);
    //go back to default rendering and let
    //SimpleApplication render the default scene
    r.setFrameBuffer(null);
}
Also used : Renderer(com.jme3.renderer.Renderer)

Example 7 with RenderManager

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

the class AbstractShadowRendererVR method postFrame.

public void postFrame(FrameBuffer out) {
    if (skipPostPass) {
        return;
    }
    if (debug) {
        displayShadowMap(renderManager.getRenderer());
    }
    getReceivers(lightReceivers);
    if (lightReceivers.size() != 0) {
        //setting params to recieving geometry list
        setMatParams(lightReceivers);
        Camera cam = viewPort.getCamera();
        //some materials in the scene does not have a post shadow technique so we're using the fall back material
        if (needsfallBackMaterial) {
            renderManager.setForcedMaterial(postshadowMat);
        }
        //forcing the post shadow technique and render state
        renderManager.setForcedTechnique(postTechniqueName);
        //rendering the post shadow pass
        viewPort.getQueue().renderShadowQueue(lightReceivers, renderManager, cam, false);
        //resetting renderManager settings
        renderManager.setForcedTechnique(null);
        renderManager.setForcedMaterial(null);
        renderManager.setCamera(cam, false);
        //clearing the params in case there are some other shadow renderers
        clearMatParams();
    }
}
Also used : Camera(com.jme3.renderer.Camera)

Example 8 with RenderManager

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

the class AbstractShadowRendererVR method renderShadowMap.

protected void renderShadowMap(int shadowMapIndex) {
    shadowMapOccluders = getOccludersToRender(shadowMapIndex, shadowMapOccluders);
    Camera shadowCam = getShadowCam(shadowMapIndex);
    //saving light view projection matrix for this split            
    lightViewProjectionsMatrices[shadowMapIndex].set(shadowCam.getViewProjectionMatrix());
    renderManager.setCamera(shadowCam, false);
    renderManager.getRenderer().setFrameBuffer(shadowFB[shadowMapIndex]);
    renderManager.getRenderer().clearBuffers(true, true, true);
    renderManager.setForcedRenderState(forcedRenderState);
    // render shadow casters to shadow map
    viewPort.getQueue().renderShadowQueue(shadowMapOccluders, renderManager, shadowCam, true);
    renderManager.setForcedRenderState(null);
}
Also used : Camera(com.jme3.renderer.Camera)

Example 9 with RenderManager

use of com.jme3.renderer.RenderManager 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 10 with RenderManager

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

the class AbstractShadowRenderer method renderShadowMap.

protected void renderShadowMap(int shadowMapIndex) {
    shadowMapOccluders = getOccludersToRender(shadowMapIndex, shadowMapOccluders);
    Camera shadowCam = getShadowCam(shadowMapIndex);
    //saving light view projection matrix for this split            
    lightViewProjectionsMatrices[shadowMapIndex].set(shadowCam.getViewProjectionMatrix());
    renderManager.setCamera(shadowCam, false);
    renderManager.getRenderer().setFrameBuffer(shadowFB[shadowMapIndex]);
    renderManager.getRenderer().clearBuffers(true, true, true);
    renderManager.setForcedRenderState(forcedRenderState);
    // render shadow casters to shadow map
    viewPort.getQueue().renderShadowQueue(shadowMapOccluders, renderManager, shadowCam, true);
    renderManager.setForcedRenderState(null);
}
Also used : Camera(com.jme3.renderer.Camera)

Aggregations

Material (com.jme3.material.Material)25 Camera (com.jme3.renderer.Camera)15 Renderer (com.jme3.renderer.Renderer)11 Vector3f (com.jme3.math.Vector3f)8 Texture2D (com.jme3.texture.Texture2D)5 DirectionalLight (com.jme3.light.DirectionalLight)4 Geometry (com.jme3.scene.Geometry)4 Picture (com.jme3.ui.Picture)4 TempVars (com.jme3.util.TempVars)4 Light (com.jme3.light.Light)3 PointLight (com.jme3.light.PointLight)3 SpotLight (com.jme3.light.SpotLight)3 Pass (com.jme3.post.Filter.Pass)3 RenderManager (com.jme3.renderer.RenderManager)3 Spatial (com.jme3.scene.Spatial)3 Shader (com.jme3.shader.Shader)3 FrameBuffer (com.jme3.texture.FrameBuffer)3 Texture (com.jme3.texture.Texture)3 Test (org.junit.Test)3 Technique (com.jme3.material.Technique)2