Search in sources :

Example 26 with Renderer

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

the class BasicShadowRenderer method postQueue.

public void postQueue(RenderQueue rq) {
    for (Spatial scene : viewPort.getScenes()) {
        ShadowUtil.getGeometriesInCamFrustum(scene, viewPort.getCamera(), ShadowMode.Receive, lightReceivers);
    }
    // update frustum points based on current camera
    Camera viewCam = viewPort.getCamera();
    ShadowUtil.updateFrustumPoints(viewCam, viewCam.getFrustumNear(), viewCam.getFrustumFar(), 1.0f, points);
    Vector3f frustaCenter = new Vector3f();
    for (Vector3f point : points) {
        frustaCenter.addLocal(point);
    }
    frustaCenter.multLocal(1f / 8f);
    // update light direction
    shadowCam.setProjectionMatrix(null);
    shadowCam.setParallelProjection(true);
    //        shadowCam.setFrustumPerspective(45, 1, 1, 20);
    shadowCam.lookAtDirection(direction, Vector3f.UNIT_Y);
    shadowCam.update();
    shadowCam.setLocation(frustaCenter);
    shadowCam.update();
    shadowCam.updateViewProjection();
    // render shadow casters to shadow map
    ShadowUtil.updateShadowCamera(viewPort, lightReceivers, shadowCam, points, shadowOccluders, shadowMapSize);
    if (shadowOccluders.size() == 0) {
        noOccluders = true;
        return;
    } else {
        noOccluders = false;
    }
    Renderer r = renderManager.getRenderer();
    renderManager.setCamera(shadowCam, false);
    renderManager.setForcedMaterial(preshadowMat);
    r.setFrameBuffer(shadowFB);
    r.clearBuffers(true, true, true);
    viewPort.getQueue().renderShadowQueue(shadowOccluders, renderManager, shadowCam, true);
    r.setFrameBuffer(viewPort.getOutputFrameBuffer());
    renderManager.setForcedMaterial(null);
    renderManager.setCamera(viewCam, false);
}
Also used : Spatial(com.jme3.scene.Spatial) Vector3f(com.jme3.math.Vector3f) Renderer(com.jme3.renderer.Renderer) Camera(com.jme3.renderer.Camera)

Example 27 with Renderer

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

the class PssmShadowRenderer method displayShadowMap.

//debug only : displays 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 28 with Renderer

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

the class OGLESContext method initInThread.

protected void initInThread() {
    created.set(true);
    logger.fine("OGLESContext create");
    logger.log(Level.FINE, "Running on thread: {0}", Thread.currentThread().getName());
    // Setup unhandled Exception Handler
    Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {

        public void uncaughtException(Thread thread, Throwable thrown) {
            listener.handleError("Exception thrown in " + thread.toString(), thrown);
        }
    });
    timer = new NanoTimer();
    Object gl = new AndroidGL();
    // gl = GLTracer.createGlesTracer((GL)gl, (GLExt)gl);
    // gl = new GLDebugES((GL)gl, (GLExt)gl);
    renderer = new GLRenderer((GL) gl, (GLExt) gl, (GLFbo) gl);
    renderer.initialize();
    JmeSystem.setSoftTextDialogInput(this);
    needClose.set(false);
}
Also used : GLExt(com.jme3.renderer.opengl.GLExt) AndroidGL(com.jme3.renderer.android.AndroidGL) GLRenderer(com.jme3.renderer.opengl.GLRenderer) GLFbo(com.jme3.renderer.opengl.GLFbo) GL(com.jme3.renderer.opengl.GL) AndroidGL(com.jme3.renderer.android.AndroidGL)

Example 29 with Renderer

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

the class FilterPostProcessor method initialize.

public void initialize(RenderManager rm, ViewPort vp) {
    renderManager = rm;
    renderer = rm.getRenderer();
    viewPort = vp;
    fsQuad = new Picture("filter full screen quad");
    fsQuad.setWidth(1);
    fsQuad.setHeight(1);
    if (fbFormat == Format.RGB111110F && !renderer.getCaps().contains(Caps.PackedFloatTexture)) {
        fbFormat = Format.RGB8;
    }
    Camera cam = vp.getCamera();
    //save view port diensions
    left = cam.getViewPortLeft();
    right = cam.getViewPortRight();
    top = cam.getViewPortTop();
    bottom = cam.getViewPortBottom();
    originalWidth = cam.getWidth();
    originalHeight = cam.getHeight();
    //first call to reshape
    reshape(vp, cam.getWidth(), cam.getHeight());
}
Also used : Picture(com.jme3.ui.Picture)

Example 30 with Renderer

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

the class FilterPostProcessor method postFrame.

public void postFrame(FrameBuffer out) {
    FrameBuffer sceneBuffer = renderFrameBuffer;
    if (renderFrameBufferMS != null && !renderer.getCaps().contains(Caps.OpenGL32)) {
        renderer.copyFrameBuffer(renderFrameBufferMS, renderFrameBuffer, true);
    } else if (renderFrameBufferMS != null) {
        sceneBuffer = renderFrameBufferMS;
    }
    renderFilterChain(renderer, sceneBuffer);
    renderer.setFrameBuffer(outputBuffer);
    //viewport can be null if no filters are enabled
    if (viewPort != null) {
        renderManager.setCamera(viewPort.getCamera(), false);
    }
}
Also used : FrameBuffer(com.jme3.texture.FrameBuffer)

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