Search in sources :

Example 6 with FilterPostProcessor

use of com.jme3.post.FilterPostProcessor in project jmonkeyengine by jMonkeyEngine.

the class TestEnvironmentMapping method simpleInitApp.

@Override
public void simpleInitApp() {
    final Node buggy = (Node) assetManager.loadModel("Models/Buggy/Buggy.j3o");
    TextureKey key = new TextureKey("Textures/Sky/Bright/BrightSky.dds", true);
    key.setGenerateMips(true);
    key.setTextureTypeHint(Texture.Type.CubeMap);
    final Texture tex = assetManager.loadTexture(key);
    for (Spatial geom : buggy.getChildren()) {
        if (geom instanceof Geometry) {
            Material m = ((Geometry) geom).getMaterial();
            m.setTexture("EnvMap", tex);
            m.setVector3("FresnelParams", new Vector3f(0.05f, 0.18f, 0.11f));
        }
    }
    flyCam.setEnabled(false);
    ChaseCamera chaseCam = new ChaseCamera(cam, inputManager);
    chaseCam.setLookAtOffset(new Vector3f(0, 0.5f, -1.0f));
    buggy.addControl(chaseCam);
    rootNode.attachChild(buggy);
    rootNode.attachChild(SkyFactory.createSky(assetManager, tex, false));
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    BloomFilter bf = new BloomFilter(BloomFilter.GlowMode.Objects);
    bf.setBloomIntensity(2.3f);
    bf.setExposurePower(0.6f);
    fpp.addFilter(bf);
    DirectionalLight l = new DirectionalLight();
    l.setDirection(new Vector3f(0, -1, -1));
    rootNode.addLight(l);
    viewPort.addProcessor(fpp);
}
Also used : Geometry(com.jme3.scene.Geometry) TextureKey(com.jme3.asset.TextureKey) Spatial(com.jme3.scene.Spatial) Node(com.jme3.scene.Node) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) ChaseCamera(com.jme3.input.ChaseCamera) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) Texture(com.jme3.texture.Texture) BloomFilter(com.jme3.post.filters.BloomFilter)

Example 7 with FilterPostProcessor

use of com.jme3.post.FilterPostProcessor in project jmonkeyengine by jMonkeyEngine.

the class TestShadowsPerf method simpleInitApp.

@Override
public void simpleInitApp() {
    Logger.getLogger("com.jme3").setLevel(Level.SEVERE);
    flyCam.setMoveSpeed(50);
    flyCam.setEnabled(false);
    viewPort.setBackgroundColor(ColorRGBA.DarkGray);
    cam.setLocation(new Vector3f(-53.952988f, 27.15874f, -32.875023f));
    cam.setRotation(new Quaternion(0.1564309f, 0.6910534f, -0.15713608f, 0.6879555f));
    //        cam.setLocation(new Vector3f(53.64627f, 130.56f, -11.247704f));
    //        cam.setRotation(new Quaternion(-6.5737107E-4f, 0.76819664f, -0.64021313f, -7.886125E-4f));   
    //// 
    cam.setFrustumFar(500);
    mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    Box b = new Box(800, 1, 700);
    b.scaleTextureCoordinates(new Vector2f(50, 50));
    Geometry ground = new Geometry("ground", b);
    ground.setMaterial(mat);
    rootNode.attachChild(ground);
    ground.setShadowMode(ShadowMode.Receive);
    Sphere sphMesh = new Sphere(32, 32, 1);
    sphMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphMesh.updateGeometry(32, 32, 1, false, false);
    TangentBinormalGenerator.generate(sphMesh);
    sphere = new Geometry("Rock Ball", sphMesh);
    sphere.setLocalTranslation(0, 5, 0);
    sphere.setMaterial(mat);
    sphere.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(sphere);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(0, -1, 0).normalizeLocal());
    dl.setColor(ColorRGBA.White);
    rootNode.addLight(dl);
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(0.7f));
    rootNode.addLight(al);
    //rootNode.setShadowMode(ShadowMode.CastAndReceive);
    createballs();
    final DirectionalLightShadowRenderer pssmRenderer = new DirectionalLightShadowRenderer(assetManager, 1024, 4);
    viewPort.addProcessor(pssmRenderer);
    //        
    //        final PssmShadowFilter pssmRenderer = new PssmShadowFilter(assetManager, 1024, 4);
    //        FilterPostProcessor fpp = new FilterPostProcessor(assetManager);        
    //        fpp.addFilter(pssmRenderer);
    //        viewPort.addProcessor(fpp);
    pssmRenderer.setLight(dl);
    pssmRenderer.setLambda(0.55f);
    pssmRenderer.setShadowIntensity(0.55f);
    pssmRenderer.setShadowCompareMode(com.jme3.shadow.CompareMode.Software);
    pssmRenderer.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
    //pssmRenderer.displayDebug();
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if (name.equals("display") && isPressed) {
                //pssmRenderer.debugFrustrums();
                System.out.println("tetetetet");
            }
            if (name.equals("add") && isPressed) {
                createballs();
            }
        }
    }, "display", "add");
    inputManager.addMapping("display", new KeyTrigger(KeyInput.KEY_SPACE));
    inputManager.addMapping("add", new KeyTrigger(KeyInput.KEY_RETURN));
}
Also used : Quaternion(com.jme3.math.Quaternion) KeyTrigger(com.jme3.input.controls.KeyTrigger) Box(com.jme3.scene.shape.Box) Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) ActionListener(com.jme3.input.controls.ActionListener) Vector2f(com.jme3.math.Vector2f) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) DirectionalLightShadowRenderer(com.jme3.shadow.DirectionalLightShadowRenderer) AmbientLight(com.jme3.light.AmbientLight)

Example 8 with FilterPostProcessor

use of com.jme3.post.FilterPostProcessor in project jmonkeyengine by jMonkeyEngine.

the class TestPbrEnv method simpleInitApp.

@Override
public void simpleInitApp() {
    assetManager.registerLoader(KTXLoader.class, "ktx");
    // put the camera in a bad position
    cam.setLocation(new Vector3f(-52.433647f, 68.69636f, -118.60924f));
    cam.setRotation(new Quaternion(0.10294232f, 0.25269797f, -0.027049713f, 0.96167296f));
    flyCam.setMoveSpeed(100);
    loadScene();
    dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 4);
    dlsr.setLight(l);
    //dlsr.setLambda(0.55f);
    dlsr.setShadowIntensity(0.5f);
    dlsr.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
    //dlsr.displayDebug();
    //       viewPort.addProcessor(dlsr);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(new ToneMapFilter(Vector3f.UNIT_XYZ.mult(6.0f)));
    SSAOFilter ssao = new SSAOFilter();
    ssao.setIntensity(5);
    fpp.addFilter(ssao);
    BloomFilter bloomFilter = new BloomFilter();
    fpp.addFilter(bloomFilter);
    fpp.addFilter(new FXAAFilter());
    //viewPort.addProcessor(fpp);
    initInputs();
    //        envManager = new EnvironmentManager();
    //        getStateManager().attach(envManager);
    //        
    envCam = new EnvironmentCamera();
    getStateManager().attach(envCam);
    debugState = new LightsDebugState();
    debugState.setProbeScale(5);
    getStateManager().attach(debugState);
    camGeom = new Geometry("camGeom", new Sphere(16, 16, 2));
    //        Material m = new Material(assetManager, "Common/MatDefs/Misc/UnshadedNodes.j3md");
    //        m.setColor("Color", ColorRGBA.Green);
    Material m = assetManager.loadMaterial("jme3test/light/pbr/pbrMat3.j3m");
    camGeom.setMaterial(m);
    camGeom.setLocalTranslation(0, 20, 0);
    camGeom.setLocalScale(5);
    rootNode.attachChild(camGeom);
    //     envManager.setScene(rootNode);
    //        MaterialDebugAppState debug = new MaterialDebugAppState();
    //        debug.registerBinding("MatDefs/PBRLighting.frag", rootNode);
    //        getStateManager().attach(debug);
    flyCam.setDragToRotate(true);
    setPauseOnLostFocus(false);
// cam.lookAt(camGeom.getWorldTranslation(), Vector3f.UNIT_Y);
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) FXAAFilter(com.jme3.post.filters.FXAAFilter) Quaternion(com.jme3.math.Quaternion) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) LightsDebugState(com.jme3.environment.util.LightsDebugState) BloomFilter(com.jme3.post.filters.BloomFilter) ToneMapFilter(com.jme3.post.filters.ToneMapFilter) Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) BoundingSphere(com.jme3.bounding.BoundingSphere) EnvironmentCamera(com.jme3.environment.EnvironmentCamera) Vector3f(com.jme3.math.Vector3f) DirectionalLightShadowRenderer(com.jme3.shadow.DirectionalLightShadowRenderer)

Example 9 with FilterPostProcessor

use of com.jme3.post.FilterPostProcessor in project jmonkeyengine by jMonkeyEngine.

the class TestPointLightShadows method simpleInitApp.

@Override
public void simpleInitApp() {
    flyCam.setMoveSpeed(10);
    cam.setLocation(new Vector3f(0.040581334f, 1.7745866f, 6.155161f));
    cam.setRotation(new Quaternion(4.3868728E-5f, 0.9999293f, -0.011230096f, 0.0039059948f));
    al = new AmbientLight(ColorRGBA.White.mult(0.02f));
    rootNode.addLight(al);
    Node scene = (Node) assetManager.loadModel("Models/Test/CornellBox.j3o");
    scene.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
    rootNode.attachChild(scene);
    rootNode.getChild("Cube").setShadowMode(RenderQueue.ShadowMode.Receive);
    lightNode = (Node) rootNode.getChild("Lamp");
    Geometry lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    //Geometry  lightMdl = new Geometry("Light", new Box(.1f,.1f,.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    lightMdl.setShadowMode(RenderQueue.ShadowMode.Off);
    lightNode.attachChild(lightMdl);
    //lightMdl.setLocalTranslation(lightNode.getLocalTranslation());
    Geometry box = new Geometry("box", new Box(0.2f, 0.2f, 0.2f));
    //Geometry  lightMdl = new Geometry("Light", new Box(.1f,.1f,.1f));
    box.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    box.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
    rootNode.attachChild(box);
    box.setLocalTranslation(-1f, 0.5f, -2);
    plsr = new PointLightShadowRenderer(assetManager, SHADOWMAP_SIZE);
    plsr.setLight((PointLight) scene.getLocalLightList().get(0));
    plsr.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
    plsr.setShadowZExtend(15);
    plsr.setShadowZFadeLength(5);
    plsr.setShadowIntensity(0.9f);
    // plsr.setFlushQueues(false);
    //plsr.displayFrustum();
    plsr.displayDebug();
    viewPort.addProcessor(plsr);
    plsf = new PointLightShadowFilter(assetManager, SHADOWMAP_SIZE);
    plsf.setLight((PointLight) scene.getLocalLightList().get(0));
    plsf.setShadowZExtend(15);
    plsf.setShadowZFadeLength(5);
    plsf.setShadowIntensity(0.8f);
    plsf.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
    plsf.setEnabled(false);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(plsf);
    viewPort.addProcessor(fpp);
    inputManager.addListener(this, "ShadowUp", "ShadowDown");
    ShadowTestUIManager uiMan = new ShadowTestUIManager(assetManager, plsr, plsf, guiNode, inputManager, viewPort);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) Node(com.jme3.scene.Node) PointLightShadowFilter(com.jme3.shadow.PointLightShadowFilter) Box(com.jme3.scene.shape.Box) PointLightShadowRenderer(com.jme3.shadow.PointLightShadowRenderer) FilterPostProcessor(com.jme3.post.FilterPostProcessor) AmbientLight(com.jme3.light.AmbientLight)

Example 10 with FilterPostProcessor

use of com.jme3.post.FilterPostProcessor in project jmonkeyengine by jMonkeyEngine.

the class TestPssmShadow method simpleInitApp.

@Override
public void simpleInitApp() {
    // put the camera in a bad position
    cam.setLocation(new Vector3f(65.25412f, 44.38738f, 9.087874f));
    cam.setRotation(new Quaternion(0.078139365f, 0.050241485f, -0.003942559f, 0.9956679f));
    flyCam.setMoveSpeed(100);
    loadScene();
    pssmRenderer = new PssmShadowRenderer(assetManager, 1024, 3);
    //pssmRenderer.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    pssmRenderer.setDirection(new Vector3f(-0.5973172f, -0.56583486f, 0.8846725f).normalizeLocal());
    pssmRenderer.setLambda(0.55f);
    pssmRenderer.setShadowIntensity(0.6f);
    pssmRenderer.setCompareMode(CompareMode.Software);
    pssmRenderer.setFilterMode(FilterMode.Dither);
    pssmRenderer.displayFrustum();
    viewPort.addProcessor(pssmRenderer);
    pssmFilter = new PssmShadowFilter(assetManager, 1024, 3);
    //pssmFilter.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    pssmRenderer.setDirection(new Vector3f(-0.5973172f, -0.56583486f, 0.8846725f).normalizeLocal());
    pssmFilter.setLambda(0.55f);
    pssmFilter.setShadowIntensity(0.6f);
    pssmFilter.setCompareMode(CompareMode.Software);
    pssmFilter.setFilterMode(FilterMode.Dither);
    pssmFilter.setEnabled(false);
    //        pssmFilter.setShadowZFadeLength(300);
    //        pssmFilter.setShadowZExtend(500);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    //  fpp.setNumSamples(4);
    fpp.addFilter(pssmFilter);
    viewPort.addProcessor(fpp);
    initInputs();
}
Also used : PssmShadowFilter(com.jme3.shadow.PssmShadowFilter) PssmShadowRenderer(com.jme3.shadow.PssmShadowRenderer) Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) FilterPostProcessor(com.jme3.post.FilterPostProcessor)

Aggregations

FilterPostProcessor (com.jme3.post.FilterPostProcessor)42 Vector3f (com.jme3.math.Vector3f)33 DirectionalLight (com.jme3.light.DirectionalLight)26 Quaternion (com.jme3.math.Quaternion)23 Geometry (com.jme3.scene.Geometry)18 Material (com.jme3.material.Material)17 Spatial (com.jme3.scene.Spatial)16 KeyTrigger (com.jme3.input.controls.KeyTrigger)14 Node (com.jme3.scene.Node)14 Box (com.jme3.scene.shape.Box)13 SSAOFilter (com.jme3.post.ssao.SSAOFilter)11 ColorRGBA (com.jme3.math.ColorRGBA)10 ActionListener (com.jme3.input.controls.ActionListener)9 AmbientLight (com.jme3.light.AmbientLight)9 BloomFilter (com.jme3.post.filters.BloomFilter)9 Sphere (com.jme3.scene.shape.Sphere)7 DirectionalLightShadowFilter (com.jme3.shadow.DirectionalLightShadowFilter)7 ChaseCamera (com.jme3.input.ChaseCamera)5 FXAAFilter (com.jme3.post.filters.FXAAFilter)4 DirectionalLightShadowRenderer (com.jme3.shadow.DirectionalLightShadowRenderer)4