Search in sources :

Example 36 with FilterPostProcessor

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

the class TestPostFilters method setupFilters.

public void setupFilters() {
    if (renderer.getCaps().contains(Caps.GLSL100)) {
        fpp = new FilterPostProcessor(assetManager);
        //     fpp.setNumSamples(4);
        // fpp.setNumSamples(4);
        //fpp.addFilter(new ColorOverlayFilter(ColorRGBA.LightGray));
        fpp.addFilter(new RadialBlurFilter());
        fade = new FadeFilter(1.0f);
        fpp.addFilter(fade);
        viewPort.addProcessor(fpp);
    }
}
Also used : FilterPostProcessor(com.jme3.post.FilterPostProcessor)

Example 37 with FilterPostProcessor

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

the class TestPosterization method simpleInitApp.

@Override
public void simpleInitApp() {
    // put the camera in a bad position
    cam.setLocation(new Vector3f(-2.336393f, 11.91392f, -7.139601f));
    cam.setRotation(new Quaternion(0.23602544f, 0.11321983f, -0.027698677f, 0.96473104f));
    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat.setFloat("Shininess", 15f);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Ambient", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Diffuse", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Specular", ColorRGBA.Yellow.mult(0.8f));
    Material matSoil = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    matSoil.setFloat("Shininess", 15f);
    matSoil.setBoolean("UseMaterialColors", true);
    matSoil.setColor("Ambient", ColorRGBA.Gray);
    matSoil.setColor("Diffuse", ColorRGBA.Black);
    matSoil.setColor("Specular", ColorRGBA.Gray);
    teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    teapot.setLocalTranslation(0, 0, 10);
    teapot.setMaterial(mat);
    teapot.setShadowMode(ShadowMode.CastAndReceive);
    teapot.setLocalScale(10.0f);
    rootNode.attachChild(teapot);
    Geometry soil = new Geometry("soil", new Box(800, 10, 700));
    soil.setLocalTranslation(0, -13, 550);
    soil.setMaterial(matSoil);
    soil.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(soil);
    DirectionalLight light = new DirectionalLight();
    light.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    light.setColor(ColorRGBA.White.mult(1.5f));
    rootNode.addLight(light);
    // load sky
    Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Bright/FullskiesBlueClear03.dds", SkyFactory.EnvMapType.CubeMap);
    sky.setCullHint(Spatial.CullHint.Never);
    rootNode.attachChild(sky);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    int numSamples = getContext().getSettings().getSamples();
    if (numSamples > 0) {
        fpp.setNumSamples(numSamples);
    }
    pf = new PosterizationFilter();
    fpp.addFilter(pf);
    viewPort.addProcessor(fpp);
    initInputs();
}
Also used : Geometry(com.jme3.scene.Geometry) Quaternion(com.jme3.math.Quaternion) Spatial(com.jme3.scene.Spatial) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) Material(com.jme3.material.Material) Box(com.jme3.scene.shape.Box) FilterPostProcessor(com.jme3.post.FilterPostProcessor) PosterizationFilter(com.jme3.post.filters.PosterizationFilter)

Example 38 with FilterPostProcessor

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

the class TestMultiPostWater method simpleInitApp.

@Override
public void simpleInitApp() {
    //      setDisplayFps(false);
    //      setDisplayStatView(false);
    Node mainScene = new Node("Main Scene");
    rootNode.attachChild(mainScene);
    createTerrain(mainScene);
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(lightDir);
    sun.setColor(ColorRGBA.White.clone().multLocal(1.7f));
    mainScene.addLight(sun);
    flyCam.setMoveSpeed(100);
    //cam.setLocation(new Vector3f(-700, 100, 300));
    //cam.setRotation(new Quaternion().fromAngleAxis(0.5f, Vector3f.UNIT_Z));
    cam.setLocation(new Vector3f(-327.21957f, 251.6459f, 126.884346f));
    cam.setRotation(new Quaternion().fromAngles(new float[] { FastMath.PI * 0.06f, FastMath.PI * 0.65f, 0 }));
    Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", false);
    sky.setLocalScale(350);
    mainScene.attachChild(sky);
    cam.setFrustumFar(4000);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    water = new WaterFilter(rootNode, lightDir);
    water.setCenter(new Vector3f(9.628218f, -15.830074f, 199.23595f));
    water.setRadius(260);
    water.setWaveScale(0.003f);
    water.setMaxAmplitude(2f);
    water.setFoamExistence(new Vector3f(1f, 4, 0.5f));
    water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
    water.setRefractionStrength(0.2f);
    water.setWaterHeight(WATER_HEIGHT);
    fpp.addFilter(water);
    WaterFilter water2 = new WaterFilter(rootNode, lightDir);
    water2.setCenter(new Vector3f(-280.46027f, -24.971727f, -271.71976f));
    water2.setRadius(260);
    water2.setWaterHeight(WATER_HEIGHT);
    water2.setUseFoam(false);
    water2.setUseRipples(false);
    water2.setDeepWaterColor(ColorRGBA.Brown);
    water2.setWaterColor(ColorRGBA.Brown.mult(2.0f));
    water2.setWaterTransparency(0.2f);
    water2.setMaxAmplitude(0.3f);
    water2.setWaveScale(0.008f);
    water2.setSpeed(0.7f);
    water2.setShoreHardness(1.0f);
    water2.setRefractionConstant(0.2f);
    water2.setShininess(0.3f);
    water2.setSunScale(1.0f);
    water2.setColorExtinction(new Vector3f(10.0f, 20.0f, 30.0f));
    fpp.addFilter(water2);
    WaterFilter water3 = new WaterFilter(rootNode, lightDir);
    water3.setCenter(new Vector3f(319.6663f, -18.367947f, -236.67674f));
    water3.setRadius(260);
    water3.setWaterHeight(WATER_HEIGHT);
    water3.setWaveScale(0.003f);
    water3.setMaxAmplitude(2f);
    water3.setFoamExistence(new Vector3f(1f, 4, 0.5f));
    water3.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
    water3.setRefractionStrength(0.2f);
    water3.setDeepWaterColor(ColorRGBA.Red);
    water3.setWaterColor(ColorRGBA.Red.mult(2.0f));
    water3.setLightColor(ColorRGBA.Red);
    fpp.addFilter(water3);
    viewPort.addProcessor(fpp);
//fpp.setNumSamples(4);
}
Also used : Quaternion(com.jme3.math.Quaternion) Spatial(com.jme3.scene.Spatial) WaterFilter(com.jme3.water.WaterFilter) Node(com.jme3.scene.Node) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) FilterPostProcessor(com.jme3.post.FilterPostProcessor)

Example 39 with FilterPostProcessor

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

the class TestPostWater method simpleInitApp.

@Override
public void simpleInitApp() {
    setDisplayFps(false);
    setDisplayStatView(false);
    Node mainScene = new Node("Main Scene");
    rootNode.attachChild(mainScene);
    createTerrain(mainScene);
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(lightDir);
    sun.setColor(ColorRGBA.White.clone().multLocal(1f));
    mainScene.addLight(sun);
    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f));
    mainScene.addLight(al);
    flyCam.setMoveSpeed(50);
    //cam.setLocation(new Vector3f(-700, 100, 300));
    //cam.setRotation(new Quaternion().fromAngleAxis(0.5f, Vector3f.UNIT_Z));
    //        cam.setLocation(new Vector3f(-327.21957f, 61.6459f, 126.884346f));
    //        cam.setRotation(new Quaternion(0.052168474f, 0.9443102f, -0.18395276f, 0.2678024f));
    cam.setLocation(new Vector3f(-370.31592f, 182.04016f, 196.81192f));
    cam.setRotation(new Quaternion(0.015302252f, 0.9304095f, -0.039101653f, 0.3641086f));
    Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", false);
    sky.setLocalScale(350);
    mainScene.attachChild(sky);
    cam.setFrustumFar(4000);
    //Water Filter
    water = new WaterFilter(rootNode, lightDir);
    water.setWaterColor(new ColorRGBA().setAsSrgb(0.0078f, 0.3176f, 0.5f, 1.0f));
    water.setDeepWaterColor(new ColorRGBA().setAsSrgb(0.0039f, 0.00196f, 0.145f, 1.0f));
    water.setUnderWaterFogDistance(80);
    water.setWaterTransparency(0.12f);
    water.setFoamIntensity(0.4f);
    water.setFoamHardness(0.3f);
    water.setFoamExistence(new Vector3f(0.8f, 8f, 1f));
    water.setReflectionDisplace(50);
    water.setRefractionConstant(0.25f);
    water.setColorExtinction(new Vector3f(30, 50, 70));
    water.setCausticsIntensity(0.4f);
    water.setWaveScale(0.003f);
    water.setMaxAmplitude(2f);
    water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
    water.setRefractionStrength(0.2f);
    water.setWaterHeight(initialWaterHeight);
    //Bloom Filter
    BloomFilter bloom = new BloomFilter();
    bloom.setExposurePower(55);
    bloom.setBloomIntensity(1.0f);
    //Light Scattering Filter
    LightScatteringFilter lsf = new LightScatteringFilter(lightDir.mult(-300));
    lsf.setLightDensity(0.5f);
    //Depth of field Filter
    DepthOfFieldFilter dof = new DepthOfFieldFilter();
    dof.setFocusDistance(0);
    dof.setFocusRange(100);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(water);
    fpp.addFilter(bloom);
    fpp.addFilter(dof);
    fpp.addFilter(lsf);
    fpp.addFilter(new FXAAFilter());
    //      fpp.addFilter(new TranslucentBucketFilter());
    int numSamples = getContext().getSettings().getSamples();
    if (numSamples > 0) {
        fpp.setNumSamples(numSamples);
    }
    uw = cam.getLocation().y < waterHeight;
    waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", false);
    waves.setLooping(true);
    waves.setReverbEnabled(true);
    if (uw) {
        waves.setDryFilter(new LowPassFilter(0.5f, 0.1f));
    } else {
        waves.setDryFilter(aboveWaterAudioFilter);
    }
    audioRenderer.playSource(waves);
    //  
    viewPort.addProcessor(fpp);
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if (isPressed) {
                if (name.equals("foam1")) {
                    water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam.jpg"));
                }
                if (name.equals("foam2")) {
                    water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
                }
                if (name.equals("foam3")) {
                    water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam3.jpg"));
                }
                if (name.equals("upRM")) {
                    water.setReflectionMapSize(Math.min(water.getReflectionMapSize() * 2, 4096));
                    System.out.println("Reflection map size : " + water.getReflectionMapSize());
                }
                if (name.equals("downRM")) {
                    water.setReflectionMapSize(Math.max(water.getReflectionMapSize() / 2, 32));
                    System.out.println("Reflection map size : " + water.getReflectionMapSize());
                }
            }
        }
    }, "foam1", "foam2", "foam3", "upRM", "downRM");
    inputManager.addMapping("foam1", new KeyTrigger(KeyInput.KEY_1));
    inputManager.addMapping("foam2", new KeyTrigger(KeyInput.KEY_2));
    inputManager.addMapping("foam3", new KeyTrigger(KeyInput.KEY_3));
    inputManager.addMapping("upRM", new KeyTrigger(KeyInput.KEY_PGUP));
    inputManager.addMapping("downRM", new KeyTrigger(KeyInput.KEY_PGDN));
//        createBox();
//        createFire();
}
Also used : FXAAFilter(com.jme3.post.filters.FXAAFilter) Texture2D(com.jme3.texture.Texture2D) LightScatteringFilter(com.jme3.post.filters.LightScatteringFilter) LowPassFilter(com.jme3.audio.LowPassFilter) Quaternion(com.jme3.math.Quaternion) AudioNode(com.jme3.audio.AudioNode) Node(com.jme3.scene.Node) KeyTrigger(com.jme3.input.controls.KeyTrigger) FilterPostProcessor(com.jme3.post.FilterPostProcessor) BloomFilter(com.jme3.post.filters.BloomFilter) DepthOfFieldFilter(com.jme3.post.filters.DepthOfFieldFilter) ColorRGBA(com.jme3.math.ColorRGBA) ActionListener(com.jme3.input.controls.ActionListener) Spatial(com.jme3.scene.Spatial) WaterFilter(com.jme3.water.WaterFilter) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) AmbientLight(com.jme3.light.AmbientLight) AudioNode(com.jme3.audio.AudioNode)

Example 40 with FilterPostProcessor

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

the class TestTransparentSSAO method simpleInitApp.

public void simpleInitApp() {
    renderManager.setAlphaToCoverage(true);
    cam.setLocation(new Vector3f(0.14914267f, 0.58147097f, 4.7686534f));
    cam.setRotation(new Quaternion(-0.0044764364f, 0.9767943f, 0.21314798f, 0.020512417f));
    //        cam.setLocation(new Vector3f(2.0606942f, 3.20342f, 6.7860126f));
    //        cam.setRotation(new Quaternion(-0.017481906f, 0.98241085f, -0.12393151f, -0.13857932f));
    viewPort.setBackgroundColor(ColorRGBA.DarkGray);
    Quad q = new Quad(20, 20);
    q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(5));
    Geometry geom = new Geometry("floor", q);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    geom.setMaterial(mat);
    geom.rotate(-FastMath.HALF_PI, 0, 0);
    geom.center();
    geom.setShadowMode(ShadowMode.Receive);
    TangentBinormalGenerator.generate(geom);
    rootNode.attachChild(geom);
    // create the geometry and attach it
    Spatial teaGeom = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
    teaGeom.setQueueBucket(Bucket.Transparent);
    teaGeom.setShadowMode(ShadowMode.Cast);
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(2));
    rootNode.addLight(al);
    DirectionalLight dl1 = new DirectionalLight();
    dl1.setDirection(new Vector3f(1, -1, 1).normalizeLocal());
    dl1.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
    rootNode.addLight(dl1);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    dl.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
    rootNode.addLight(dl);
    rootNode.attachChild(teaGeom);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    //0.49997783f, 42.598858f, 35.999966f, 0.39299846f
    SSAOFilter ssao = new SSAOFilter();
    fpp.addFilter(ssao);
    SSAOUI ui = new SSAOUI(inputManager, ssao);
    viewPort.addProcessor(fpp);
}
Also used : Geometry(com.jme3.scene.Geometry) SSAOFilter(com.jme3.post.ssao.SSAOFilter) Quad(com.jme3.scene.shape.Quad) Spatial(com.jme3.scene.Spatial) DirectionalLight(com.jme3.light.DirectionalLight) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) AmbientLight(com.jme3.light.AmbientLight)

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