Search in sources :

Example 1 with FilterPostProcessor

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

the class TestPostWaterLake method simpleInitApp.

public void simpleInitApp() {
    this.flyCam.setMoveSpeed(10);
    cam.setLocation(new Vector3f(-27.0f, 1.0f, 75.0f));
    //  cam.setRotation(new Quaternion(0.03f, 0.9f, 0f, 0.4f));
    // load sky
    rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));
    File file = new File("wildhouse.zip");
    if (file.exists()) {
        useHttp = false;
    }
    // load the level from zip or http zip
    if (useHttp) {
        assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/wildhouse.zip", HttpZipLocator.class);
    } else {
        assetManager.registerLocator("wildhouse.zip", ZipLocator.class);
    }
    Spatial scene = assetManager.loadModel("main.scene");
    rootNode.attachChild(scene);
    DirectionalLight sun = new DirectionalLight();
    Vector3f lightDir = new Vector3f(-0.37352666f, -0.50444174f, -0.7784704f);
    sun.setDirection(lightDir);
    sun.setColor(ColorRGBA.White.clone().multLocal(2));
    scene.addLight(sun);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    final WaterFilter water = new WaterFilter(rootNode, lightDir);
    water.setWaterHeight(-20);
    water.setUseFoam(false);
    water.setUseRipples(false);
    water.setDeepWaterColor(ColorRGBA.Brown);
    water.setWaterColor(ColorRGBA.Brown.mult(2.0f));
    water.setWaterTransparency(0.2f);
    water.setMaxAmplitude(0.3f);
    water.setWaveScale(0.008f);
    water.setSpeed(0.7f);
    water.setShoreHardness(1.0f);
    water.setRefractionConstant(0.2f);
    water.setShininess(0.3f);
    water.setSunScale(1.0f);
    water.setColorExtinction(new Vector3f(10.0f, 20.0f, 30.0f));
    fpp.addFilter(water);
    viewPort.addProcessor(fpp);
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if (isPressed) {
                if (water.isUseHQShoreline()) {
                    water.setUseHQShoreline(false);
                } else {
                    water.setUseHQShoreline(true);
                }
            }
        }
    }, "HQ");
    inputManager.addMapping("HQ", new KeyTrigger(keyInput.KEY_SPACE));
}
Also used : ActionListener(com.jme3.input.controls.ActionListener) Spatial(com.jme3.scene.Spatial) WaterFilter(com.jme3.water.WaterFilter) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) KeyTrigger(com.jme3.input.controls.KeyTrigger) FilterPostProcessor(com.jme3.post.FilterPostProcessor) File(java.io.File)

Example 2 with FilterPostProcessor

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

the class TestCinematic method createScene.

private void createScene() {
    model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    model.center();
    model.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(model);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Cyan);
    teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    teapot.setLocalTranslation(10, 0, 10);
    teapot.setMaterial(mat);
    teapot.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(teapot);
    Material matSoil = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    matSoil.setBoolean("UseMaterialColors", true);
    matSoil.setColor("Ambient", ColorRGBA.Gray);
    matSoil.setColor("Diffuse", ColorRGBA.Green);
    matSoil.setColor("Specular", ColorRGBA.Black);
    Geometry soil = new Geometry("soil", new Box(50, 1, 50));
    soil.setLocalTranslation(0, -6, 0);
    soil.setMaterial(matSoil);
    soil.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(soil);
    DirectionalLight light = new DirectionalLight();
    light.setDirection(new Vector3f(0, -1, -1).normalizeLocal());
    light.setColor(ColorRGBA.White.mult(1.5f));
    rootNode.addLight(light);
    fpp = new FilterPostProcessor(assetManager);
    fade = new FadeFilter();
    fpp.addFilter(fade);
    if (renderer.getCaps().contains(Caps.GLSL100)) {
        PssmShadowRenderer pssm = new PssmShadowRenderer(assetManager, 512, 1);
        pssm.setDirection(new Vector3f(0, -1, -1).normalizeLocal());
        pssm.setShadowIntensity(0.4f);
        viewPort.addProcessor(pssm);
        viewPort.addProcessor(fpp);
    }
}
Also used : Geometry(com.jme3.scene.Geometry) PssmShadowRenderer(com.jme3.shadow.PssmShadowRenderer) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) Box(com.jme3.scene.shape.Box) FilterPostProcessor(com.jme3.post.FilterPostProcessor) FadeFilter(com.jme3.post.filters.FadeFilter)

Example 3 with FilterPostProcessor

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

the class TestJaime method setupLights.

public void setupLights() {
    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(0.1f, 0.1f, 0.1f, 1));
    rootNode.addLight(al);
    SpotLight sl = new SpotLight();
    sl.setColor(ColorRGBA.White.mult(1.0f));
    sl.setPosition(new Vector3f(1.2074411f, 10.6868908f, 4.1489987f));
    sl.setDirection(sl.getPosition().mult(-1));
    sl.setSpotOuterAngle(0.1f);
    sl.setSpotInnerAngle(0.004f);
    rootNode.addLight(sl);
    //pointlight to fake indirect light coming from the ground
    PointLight pl = new PointLight();
    pl.setColor(ColorRGBA.White.mult(1.5f));
    pl.setPosition(new Vector3f(0, 0, 1));
    pl.setRadius(2);
    rootNode.addLight(pl);
    SpotLightShadowRenderer shadows = new SpotLightShadowRenderer(assetManager, 1024);
    shadows.setLight(sl);
    shadows.setShadowIntensity(0.3f);
    shadows.setEdgeFilteringMode(EdgeFilteringMode.PCF8);
    viewPort.addProcessor(shadows);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    SSAOFilter filter = new SSAOFilter(0.10997847f, 0.440001f, 0.39999998f, -0.008000026f);
    ;
    fpp.addFilter(filter);
    fpp.addFilter(new FXAAFilter());
    fpp.addFilter(new FXAAFilter());
    viewPort.addProcessor(fpp);
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) FXAAFilter(com.jme3.post.filters.FXAAFilter) ColorRGBA(com.jme3.math.ColorRGBA) Vector3f(com.jme3.math.Vector3f) FilterPostProcessor(com.jme3.post.FilterPostProcessor) PointLight(com.jme3.light.PointLight) SpotLightShadowRenderer(com.jme3.shadow.SpotLightShadowRenderer) SpotLight(com.jme3.light.SpotLight) AmbientLight(com.jme3.light.AmbientLight)

Example 4 with FilterPostProcessor

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

the class TestColorApp method simpleInitApp.

@Override
public void simpleInitApp() {
    // Lights
    DirectionalLight sun = new DirectionalLight();
    Vector3f sunPosition = new Vector3f(1, -1, 1);
    sun.setDirection(sunPosition);
    sun.setColor(new ColorRGBA(1f, 1f, 1f, 1f));
    rootNode.addLight(sun);
    //DirectionalLightShadowFilter sun_renderer = new DirectionalLightShadowFilter(assetManager, 2048, 4);
    DirectionalLightShadowRenderer sun_renderer = new DirectionalLightShadowRenderer(assetManager, 2048, 1);
    sun_renderer.setLight(sun);
    viewPort.addProcessor(sun_renderer);
    //        FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    //        fpp.addFilter(sun_renderer);
    //        viewPort.addProcessor(fpp);
    rootNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
    // Camera
    viewPort.setBackgroundColor(new ColorRGBA(.6f, .6f, .6f, 1f));
    ChaseCamera chaseCam = new ChaseCamera(cam, inputManager);
    // Objects
    // Ground Object
    final Geometry groundBoxWhite = new Geometry("Box", new Box(7.5f, 7.5f, .25f));
    float[] f = { -FastMath.PI / 2, 3 * FastMath.PI / 2, 0f };
    groundBoxWhite.setLocalRotation(new Quaternion(f));
    groundBoxWhite.move(7.5f, -.75f, 7.5f);
    final Material groundMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    groundMaterial.setColor("Diffuse", new ColorRGBA(.9f, .9f, .9f, .9f));
    groundBoxWhite.setMaterial(groundMaterial);
    groundBoxWhite.addControl(chaseCam);
    rootNode.attachChild(groundBoxWhite);
    // Planter
    Geometry planterBox = new Geometry("Box", new Box(.5f, .5f, .5f));
    final Material planterMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    planterMaterial.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
    planterBox.setMaterial(groundMaterial);
    planterBox.setLocalTranslation(10, 0, 9);
    rootNode.attachChild(planterBox);
    // Action!
    inputManager.addMapping("on", new KeyTrigger(KeyInput.KEY_Z));
    inputManager.addMapping("off", new KeyTrigger(KeyInput.KEY_X));
    inputManager.addListener(new AnalogListener() {

        @Override
        public void onAnalog(String s, float v, float v1) {
            if (s.equals("on")) {
                groundBoxWhite.setMaterial(planterMaterial);
            }
            if (s.equals("off")) {
                groundBoxWhite.setMaterial(groundMaterial);
            }
        }
    }, "on", "off");
    inputEnabled = true;
}
Also used : Quaternion(com.jme3.math.Quaternion) KeyTrigger(com.jme3.input.controls.KeyTrigger) ChaseCamera(com.jme3.input.ChaseCamera) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) Geometry(com.jme3.scene.Geometry) ColorRGBA(com.jme3.math.ColorRGBA) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) DirectionalLightShadowRenderer(com.jme3.shadow.DirectionalLightShadowRenderer) AnalogListener(com.jme3.input.controls.AnalogListener)

Example 5 with FilterPostProcessor

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

the class TestDirectionalLightShadow 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));
    cam.setLocation(new Vector3f(3.3720117f, 42.838284f, -83.43792f));
    cam.setRotation(new Quaternion(0.13833192f, -0.08969371f, 0.012581267f, 0.9862358f));
    flyCam.setMoveSpeed(100);
    loadScene();
    dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 3);
    dlsr.setLight(l);
    dlsr.setLambda(0.55f);
    dlsr.setShadowIntensity(0.8f);
    dlsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
    dlsr.displayDebug();
    viewPort.addProcessor(dlsr);
    dlsf = new DirectionalLightShadowFilter(assetManager, SHADOWMAP_SIZE, 3);
    dlsf.setLight(l);
    dlsf.setLambda(0.55f);
    dlsf.setShadowIntensity(0.8f);
    dlsf.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
    dlsf.setEnabled(false);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(dlsf);
    viewPort.addProcessor(fpp);
    initInputs();
}
Also used : Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) DirectionalLightShadowRenderer(com.jme3.shadow.DirectionalLightShadowRenderer) FilterPostProcessor(com.jme3.post.FilterPostProcessor) DirectionalLightShadowFilter(com.jme3.shadow.DirectionalLightShadowFilter)

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