Search in sources :

Example 1 with ColorOverlayFilter

use of com.jme3.post.filters.ColorOverlayFilter in project jmonkeyengine by jMonkeyEngine.

the class TestMultiplesFilters method simpleInitApp.

public void simpleInitApp() {
    this.flyCam.setMoveSpeed(10);
    cam.setLocation(new Vector3f(6.0344796f, 1.5054002f, 55.572033f));
    cam.setRotation(new Quaternion(0.0016069f, 0.9810479f, -0.008143323f, 0.19358753f));
    // load sky
    rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", 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");
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-0.4790551f, -0.39247334f, -0.7851566f));
    sun.setColor(ColorRGBA.White.clone().multLocal(2));
    scene.addLight(sun);
    fpp = new FilterPostProcessor(assetManager);
    //  fpp.setNumSamples(4);
    ssaoFilter = new SSAOFilter(0.92f, 2.2f, 0.46f, 0.2f);
    final WaterFilter water = new WaterFilter(rootNode, new Vector3f(-0.4790551f, -0.39247334f, -0.7851566f));
    water.setWaterHeight(-20);
    SSAOUI ui = new SSAOUI(inputManager, ssaoFilter);
    final BloomFilter bloom = new BloomFilter();
    final ColorOverlayFilter overlay = new ColorOverlayFilter(ColorRGBA.LightGray);
    fpp.addFilter(ssaoFilter);
    fpp.addFilter(water);
    fpp.addFilter(bloom);
    fpp.addFilter(overlay);
    viewPort.addProcessor(fpp);
    rootNode.attachChild(scene);
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if ("toggleSSAO".equals(name) && isPressed) {
                if (ssaoFilter.isEnabled()) {
                    ssaoFilter.setEnabled(false);
                } else {
                    ssaoFilter.setEnabled(true);
                }
            }
            if ("toggleWater".equals(name) && isPressed) {
                if (water.isEnabled()) {
                    water.setEnabled(false);
                } else {
                    water.setEnabled(true);
                }
            }
            if ("toggleBloom".equals(name) && isPressed) {
                if (bloom.isEnabled()) {
                    bloom.setEnabled(false);
                } else {
                    bloom.setEnabled(true);
                }
            }
            if ("toggleOverlay".equals(name) && isPressed) {
                if (overlay.isEnabled()) {
                    overlay.setEnabled(false);
                } else {
                    overlay.setEnabled(true);
                }
            }
        }
    }, "toggleSSAO", "toggleBloom", "toggleWater", "toggleOverlay");
    inputManager.addMapping("toggleSSAO", new KeyTrigger(KeyInput.KEY_1));
    inputManager.addMapping("toggleWater", new KeyTrigger(KeyInput.KEY_2));
    inputManager.addMapping("toggleBloom", new KeyTrigger(KeyInput.KEY_3));
    inputManager.addMapping("toggleOverlay", new KeyTrigger(KeyInput.KEY_4));
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) Quaternion(com.jme3.math.Quaternion) KeyTrigger(com.jme3.input.controls.KeyTrigger) FilterPostProcessor(com.jme3.post.FilterPostProcessor) BloomFilter(com.jme3.post.filters.BloomFilter) ColorOverlayFilter(com.jme3.post.filters.ColorOverlayFilter) 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)

Example 2 with ColorOverlayFilter

use of com.jme3.post.filters.ColorOverlayFilter in project jmonkeyengine by jMonkeyEngine.

the class TestPostFiltersCompositing method simpleInitApp.

public void simpleInitApp() {
    this.flyCam.setMoveSpeed(10);
    cam.setLocation(new Vector3f(0.028406568f, 2.015769f, 7.386517f));
    cam.setRotation(new Quaternion(-1.0729783E-5f, 0.9999721f, -0.0073241726f, -0.0014647911f));
    makeScene();
    //Creating the main view port post processor
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(new ColorOverlayFilter(ColorRGBA.Blue));
    viewPort.addProcessor(fpp);
    //creating a frame buffer for the mainviewport
    FrameBuffer mainVPFrameBuffer = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1);
    Texture2D mainVPTexture = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8);
    mainVPFrameBuffer.addColorTexture(mainVPTexture);
    mainVPFrameBuffer.setDepthBuffer(Image.Format.Depth);
    viewPort.setOutputFrameBuffer(mainVPFrameBuffer);
    //creating the post processor for the gui viewport
    final FilterPostProcessor guifpp = new FilterPostProcessor(assetManager);
    guifpp.setFrameBufferFormat(Image.Format.RGBA8);
    guifpp.addFilter(new ColorOverlayFilter(ColorRGBA.Red));
    //this will compose the main viewport texture with the guiviewport back buffer.
    //Note that you can switch the order of the filters so that guiviewport filters are applied or not to the main viewport texture
    guifpp.addFilter(new ComposeFilter(mainVPTexture));
    guiViewPort.addProcessor(guifpp);
    //compositing is done by mixing texture depending on the alpha channel, 
    //it's important that the guiviewport clear color alpha value is set to 0
    guiViewPort.setBackgroundColor(ColorRGBA.BlackNoAlpha);
    guiViewPort.setClearColor(true);
}
Also used : Texture2D(com.jme3.texture.Texture2D) ColorOverlayFilter(com.jme3.post.filters.ColorOverlayFilter) ComposeFilter(com.jme3.post.filters.ComposeFilter) Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) FilterPostProcessor(com.jme3.post.FilterPostProcessor) FrameBuffer(com.jme3.texture.FrameBuffer)

Example 3 with ColorOverlayFilter

use of com.jme3.post.filters.ColorOverlayFilter 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 4 with ColorOverlayFilter

use of com.jme3.post.filters.ColorOverlayFilter in project chordatlas by twak.

the class Tweed method simpleInitApp.

public void simpleInitApp() {
    // TweedSettings.load( new File ( Tweed.DATA ) );
    point = new PointLight();
    point.setEnabled(true);
    point.setColor(ColorRGBA.White.mult(4));
    point.setRadius(50);
    rootNode.addLight(point);
    sun = new DirectionalLight();
    // sun.setDirection(new Vector3f(-0.0f, -1f, -0f).normalizeLocal());
    sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal());
    sun.setColor(new ColorRGBA(1f, 0.95f, 0.99f, 1f));
    rootNode.addLight(sun);
    // enable multiple lights
    renderManager.setPreferredLightMode(LightMode.SinglePass);
    renderManager.setSinglePassLightBatchSize(16);
    ambient = new AmbientLight();
    rootNode.addLight(ambient);
    setAmbient(0);
    setDisplayFps(false);
    setDisplayStatView(false);
    clearBackground();
    buildBackground();
    getFlyByCamera().setDragToRotate(true);
    setTool(tools[0]);
    debug = new Node("dbg");
    rootNode.attachChild(debug);
    // String folder = ; // data-source
    // SpotLightShadowRenderer shadows = new SpotLightShadowRenderer(assetManager, 1024);
    // shadows.setLight(sun);
    // shadows.setShadowIntensity(0.3f);
    // shadows.setEdgeFilteringMode(EdgeFilteringMode.PCF8);
    // viewPort.addProcessor(shadows);
    cam.setLocation(TweedSettings.settings.cameraLocation);
    cam.setRotation(TweedSettings.settings.cameraOrientation);
    setFov(0);
    setCameraSpeed(0);
    if (false) {
        // TweedSettings.settings.SSAO ) {
        FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
        SSAOFilter filter = new SSAOFilter(0.50997847f, 1.440001f, 1.39999998f, 0);
        // fpp.addFilter( new ColorOverlayFilter( ColorRGBA.Magenta ));
        fpp.addFilter(filter);
        fpp.addFilter(new FXAAFilter());
        viewPort.addProcessor(fpp);
    }
    TweedSettings.loadDefault();
    inputManager.addMapping(MOUSE_MOVE, new MouseAxisTrigger(MouseInput.AXIS_X, false));
    inputManager.addMapping(MOUSE_MOVE, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
    inputManager.addMapping(MOUSE_MOVE, new MouseAxisTrigger(MouseInput.AXIS_X, true));
    inputManager.addMapping(MOUSE_MOVE, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
    inputManager.addListener(moveListener, MOUSE_MOVE);
    inputManager.addMapping(CLICK, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
    inputManager.addListener(analogListener, CLICK);
    inputManager.addMapping(SPEED_UP, new KeyTrigger(KeyInput.KEY_UP));
    inputManager.addMapping(SPEED_DOWN, new KeyTrigger(KeyInput.KEY_DOWN));
    inputManager.addMapping(AMBIENT_UP, new KeyTrigger(KeyInput.KEY_RIGHT));
    inputManager.addMapping(AMBIENT_DOWN, new KeyTrigger(KeyInput.KEY_LEFT));
    inputManager.addMapping(FOV_UP, new KeyTrigger(KeyInput.KEY_PGUP));
    inputManager.addMapping(FOV_DOWN, new KeyTrigger(KeyInput.KEY_PGDN));
    inputManager.addMapping(TOGGLE_ORTHO, new KeyTrigger(KeyInput.KEY_O));
    inputManager.addListener(new com.jme3.input.controls.ActionListener() {

        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            if (name == SPEED_UP)
                setCameraSpeed(+1);
            else
                setCameraSpeed(-1);
        }
    }, SPEED_UP, SPEED_DOWN);
    inputManager.addListener(new com.jme3.input.controls.ActionListener() {

        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            if (!isPressed)
                return;
            if (name == AMBIENT_UP)
                setAmbient(+1);
            else
                setAmbient(-1);
        }
    }, AMBIENT_UP, AMBIENT_DOWN);
    inputManager.addListener(new com.jme3.input.controls.ActionListener() {

        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            if (!isPressed)
                return;
            if (name == FOV_UP)
                setFov(+1);
            else
                setFov(-1);
        }
    }, FOV_UP, FOV_DOWN);
    inputManager.addListener(new com.jme3.input.controls.ActionListener() {

        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            if (isPressed) {
                TweedSettings.settings.ortho = !TweedSettings.settings.ortho;
                setCameraPerspective();
            }
        }
    }, TOGGLE_ORTHO);
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) FXAAFilter(com.jme3.post.filters.FXAAFilter) Node(com.jme3.scene.Node) MouseAxisTrigger(com.jme3.input.controls.MouseAxisTrigger) KeyTrigger(com.jme3.input.controls.KeyTrigger) FilterPostProcessor(com.jme3.post.FilterPostProcessor) ColorRGBA(com.jme3.math.ColorRGBA) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) PointLight(com.jme3.light.PointLight) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger) AmbientLight(com.jme3.light.AmbientLight)

Aggregations

FilterPostProcessor (com.jme3.post.FilterPostProcessor)4 Vector3f (com.jme3.math.Vector3f)3 KeyTrigger (com.jme3.input.controls.KeyTrigger)2 DirectionalLight (com.jme3.light.DirectionalLight)2 Quaternion (com.jme3.math.Quaternion)2 ColorOverlayFilter (com.jme3.post.filters.ColorOverlayFilter)2 SSAOFilter (com.jme3.post.ssao.SSAOFilter)2 ActionListener (com.jme3.input.controls.ActionListener)1 MouseAxisTrigger (com.jme3.input.controls.MouseAxisTrigger)1 MouseButtonTrigger (com.jme3.input.controls.MouseButtonTrigger)1 AmbientLight (com.jme3.light.AmbientLight)1 PointLight (com.jme3.light.PointLight)1 ColorRGBA (com.jme3.math.ColorRGBA)1 BloomFilter (com.jme3.post.filters.BloomFilter)1 ComposeFilter (com.jme3.post.filters.ComposeFilter)1 FXAAFilter (com.jme3.post.filters.FXAAFilter)1 Node (com.jme3.scene.Node)1 Spatial (com.jme3.scene.Spatial)1 FrameBuffer (com.jme3.texture.FrameBuffer)1 Texture2D (com.jme3.texture.Texture2D)1