Search in sources :

Example 36 with RenderManager

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

the class AbstractShadowRenderer 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 37 with RenderManager

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

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

the class PssmShadowRenderer method postFrame.

public void postFrame(FrameBuffer out) {
    if (debug) {
        displayShadowMap(renderManager.getRenderer());
    }
    if (!noOccluders) {
        //setting params to recieving geometry list
        setMatParams();
        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, true);
        //resetting renderManager settings
        renderManager.setForcedTechnique(null);
        renderManager.setForcedMaterial(null);
        renderManager.setCamera(cam, false);
    }
}
Also used : Camera(com.jme3.renderer.Camera)

Example 39 with RenderManager

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

the class OpaqueComparatorTest method testSortByTechnique.

@Test
public void testSortByTechnique() {
    Material lightingMatDefault = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingPreShadow = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingPostShadow = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingMatPreNormalPass = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingMatGBuf = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Material lightingMatGlow = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    lightingMatDefault.setName("TechDefault");
    lightingMatDefault.selectTechnique(TechniqueDef.DEFAULT_TECHNIQUE_NAME, renderManager);
    lightingPostShadow.setName("TechPostShad");
    lightingPostShadow.selectTechnique("PostShadow", renderManager);
    lightingPreShadow.setName("TechPreShad");
    lightingPreShadow.selectTechnique("PreShadow", renderManager);
    lightingMatPreNormalPass.setName("TechNorm");
    lightingMatPreNormalPass.selectTechnique("PreNormalPass", renderManager);
    lightingMatGlow.setName("TechGlow");
    lightingMatGlow.selectTechnique("Glow", renderManager);
    testSort(lightingMatGlow, lightingPreShadow, lightingMatPreNormalPass, lightingMatDefault, lightingPostShadow);
}
Also used : Material(com.jme3.material.Material) Test(org.junit.Test)

Example 40 with RenderManager

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

the class FilterPostProcessor method initFilter.

/**
     * init the given filter
     * @param filter
     * @param vp 
     */
private void initFilter(Filter filter, ViewPort vp) {
    filter.setProcessor(this);
    if (filter.isRequiresDepthTexture()) {
        if (!computeDepth && renderFrameBuffer != null) {
            depthTexture = new Texture2D(width, height, Format.Depth24);
            renderFrameBuffer.setDepthTexture(depthTexture);
        }
        computeDepth = true;
        filter.init(assetManager, renderManager, vp, width, height);
        filter.setDepthTexture(depthTexture);
    } else {
        filter.init(assetManager, renderManager, vp, width, height);
    }
}
Also used : Texture2D(com.jme3.texture.Texture2D)

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