com.jme3.post.FilterPostProcessor Java Examples

The following examples show how to use com.jme3.post.FilterPostProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestToneMapFilter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void simpleInitApp() {
    System.out.println("== Tone Mapping Sample ==");
    System.out.println(" SPACE:\tToggle tone-mapping OFF or ON");
    System.out.println(" Y:\tIncrease white-point");
    System.out.println(" H:\tDecrease white-point");
    
    fpp = new FilterPostProcessor(assetManager);
    toneMapFilter = new ToneMapFilter();
    fpp.addFilter(toneMapFilter);
    viewPort.addProcessor(fpp);
    
    rootNode.attachChild(createHDRBox());
    
    cam.setLocation(new Vector3f(0f,0f,3f));
    
    initInputs();
}
 
Example #2
Source File: TestSSAO.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    cam.setLocation(new Vector3f(68.45442f, 8.235511f, 7.9676695f));
    cam.setRotation(new Quaternion(0.046916496f, -0.69500375f, 0.045538206f, 0.7160271f));


    flyCam.setMoveSpeed(50);

    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Texture diff = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg");
    diff.setWrap(Texture.WrapMode.Repeat);
    Texture norm = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall_normal.jpg");
    norm.setWrap(Texture.WrapMode.Repeat);
    mat.setTexture("DiffuseMap", diff);
    mat.setTexture("NormalMap", norm);
    mat.setFloat("Shininess", 2.0f);


    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(1.8f, 1.8f, 1.8f, 1.0f));

    rootNode.addLight(al);

    model = (Geometry) assetManager.loadModel("Models/Sponza/Sponza.j3o");
    model.getMesh().scaleTextureCoordinates(new Vector2f(2, 2));

    model.setMaterial(mat);

    rootNode.attachChild(model);

    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    SSAOFilter ssaoFilter = new SSAOFilter(2.9299974f,32.920483f,5.8100376f,0.091000035f);;
    ssaoFilter.setApproximateNormals(true);
    fpp.addFilter(ssaoFilter);
    SSAOUI ui = new SSAOUI(inputManager, ssaoFilter);

    viewPort.addProcessor(fpp);
}
 
Example #3
Source File: TestFog.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    this.flyCam.setMoveSpeed(50);
    Node mainScene=new Node();
    cam.setLocation(new Vector3f(-34.74095f, 95.21318f, -287.4945f));
    cam.setRotation(new Quaternion(0.023536969f, 0.9361278f, -0.016098259f, -0.35050195f));

    // load sky
    mainScene.attachChild(SkyFactory.createSky(assetManager, 
            "Textures/Sky/Bright/BrightSky.dds", 
            SkyFactory.EnvMapType.CubeMap));
    createTerrain(mainScene);



    DirectionalLight sun = new DirectionalLight();
    Vector3f lightDir=new Vector3f(-0.37352666f, -0.50444174f, -0.7784704f);
    sun.setDirection(lightDir);
    sun.setColor(ColorRGBA.White.clone().multLocal(2));
    mainScene.addLight(sun);

    rootNode.attachChild(mainScene);

    fpp=new FilterPostProcessor(assetManager);
    //fpp.setNumSamples(4);
    int numSamples = getContext().getSettings().getSamples();
    if( numSamples > 0 ) {
        fpp.setNumSamples(numSamples); 
    }
    fog=new FogFilter();
    fog.setFogColor(new ColorRGBA(0.9f, 0.9f, 0.9f, 1.0f));
    fog.setFogDistance(155);
    fog.setFogDensity(1.0f);
    fpp.addFilter(fog);
    viewPort.addProcessor(fpp);
    initInputs();
}
 
Example #4
Source File: NewFilterPopup.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void addFilterUndo(final FilterPostProcessor fpp, final Filter filter) {
    //add undo
    if (fpp != null && filter != null) {
        Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {

            @Override
            public void sceneUndo() throws CannotUndoException {
                fpp.removeFilter(filter);
            }

            @Override
            public void sceneRedo() throws CannotRedoException {
                fpp.addFilter(filter);
            }

            @Override
            public void awtRedo() {
                filterNode.refresh();
            }

            @Override
            public void awtUndo() {
                filterNode.refresh();
            }
        });
    }
}
 
Example #5
Source File: FilterExplorerTopComponent.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public synchronized void setFilterEnabled(final boolean enabled) {
    if (added == enabled) {
        return;
    }
    if (currentFile != null) {
        added = enabled;
        final FilterPostProcessor fpp = this.node.getFilterPostProcessor();
        SceneApplication.getApplication().enqueue(new Callable() {

            public Object call() throws Exception {
                if (enabled) {
                    SceneApplication.getApplication().getViewPort().addProcessor(fpp);
                    Logger.getLogger(FilterExplorerTopComponent.class.getName()).log(Level.INFO, "Enabled post filters");
                } else {
                    for (Iterator<SceneProcessor> it = SceneApplication.getApplication().getViewPort().getProcessors().iterator(); it.hasNext();) {
                        SceneProcessor proc = it.next();
                        if (proc instanceof FilterPostProcessor) {
                            it.remove();
                            proc.cleanup();
                        }
                    }
                    //  SceneApplication.getApplication().getViewPort().removeProcessor(fpp);
                    Logger.getLogger(FilterExplorerTopComponent.class.getName()).log(Level.INFO, "Disabled post filters");
                }
                return null;
            }
        });

    }
}
 
Example #6
Source File: TestJaime.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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);
}
 
Example #7
Source File: BaseExternalTest.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
public void simpleInitApp() {
    renderManager.setPreferredLightMode(TechniqueDef.LightMode.SinglePass);
    renderManager.setSinglePassLightBatchSize(15);

    postProcessor = new FilterPostProcessor(assetManager);
    postProcessor.initialize(renderManager, viewPort);

    viewPort.addProcessor(postProcessor);
    viewPort.setBackgroundColor(new ColorRGBA(50 / 255F, 50 / 255F, 50 / 255F, 1F));

    cam.setFrustumPerspective(55, (float) cam.getWidth() / cam.getHeight(), 1f, Integer.MAX_VALUE);
}
 
Example #8
Source File: TestCartoonEdge.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupFilters(){
    if (renderer.getCaps().contains(Caps.GLSL100)){
        fpp=new FilterPostProcessor(assetManager);
        //fpp.setNumSamples(4);
        int numSamples = getContext().getSettings().getSamples();
        if( numSamples > 0 ) {
            fpp.setNumSamples(numSamples); 
        }
        CartoonEdgeFilter toon=new CartoonEdgeFilter();
        toon.setEdgeColor(ColorRGBA.Yellow);
        fpp.addFilter(toon);
        viewPort.addProcessor(fpp);
    }
}
 
Example #9
Source File: TestHoverTank.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    Node tank = (Node) assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml");

    flyCam.setEnabled(false);
    ChaseCamera chaseCam = new ChaseCamera(cam, tank, inputManager);
    chaseCam.setSmoothMotion(true);
    chaseCam.setMaxDistance(100000);
    chaseCam.setMinVerticalRotation(-FastMath.PI / 2);
    viewPort.setBackgroundColor(ColorRGBA.DarkGray);

    Geometry tankGeom = (Geometry) tank.getChild(0);
    LodControl control = new LodControl();
    tankGeom.addControl(control);
    rootNode.attachChild(tank);

    Vector3f lightDir = new Vector3f(-0.8719428f, -0.46824604f, 0.14304268f);
    DirectionalLight dl = new DirectionalLight();
    dl.setColor(new ColorRGBA(1.0f, 0.92f, 0.75f, 1f));
    dl.setDirection(lightDir);

    Vector3f lightDir2 = new Vector3f(0.70518064f, 0.5902297f, -0.39287305f);
    DirectionalLight dl2 = new DirectionalLight();
    dl2.setColor(new ColorRGBA(0.7f, 0.85f, 1.0f, 1f));
    dl2.setDirection(lightDir2);

    rootNode.addLight(dl);
    rootNode.addLight(dl2);
    rootNode.attachChild(tank);

    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    BloomFilter bf = new BloomFilter(BloomFilter.GlowMode.Objects);
    bf.setBloomIntensity(2.0f);
    bf.setExposurePower(1.3f);
    fpp.addFilter(bf);
    BloomUI bui = new BloomUI(inputManager, bf);
    viewPort.addProcessor(fpp);
}
 
Example #10
Source File: NewBloomFilterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected Filter doCreateFilter(FilterPostProcessor parent, Object configuration) {
    if (configuration != null) {
        WizardDescriptor wiz = (WizardDescriptor) configuration;
        if (wiz.getProperty("mode").equals("Scene")) {
            return new BloomFilter(BloomFilter.GlowMode.Scene);
        } else {
            return new BloomFilter(BloomFilter.GlowMode.Objects);
        }
    }
    return null;
}
 
Example #11
Source File: TestEnvironmentMapping.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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.setAsCube(true);
    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);
    
    viewPort.addProcessor(fpp);
}
 
Example #12
Source File: TestPostFiltersCompositing.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
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);


}
 
Example #13
Source File: TestPostFilters.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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);
    }
}
 
Example #14
Source File: TestPostFilters.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setupFilters() {
    if (renderer.getCaps().contains(Caps.GLSL100)) {
        fpp = new FilterPostProcessor(assetManager);
        // fpp.setNumSamples(4);
        fpp.addFilter(new ColorOverlayFilter(ColorRGBA.LightGray));
        fpp.addFilter(new RadialBlurFilter());
        //fade=new FadeFilter(1.0f);
        //fpp.addFilter(fade);


        viewPort.addProcessor(fpp);
    }
}
 
Example #15
Source File: TestDirectionalLightShadow.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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();
    }
 
Example #16
Source File: TestSSAO.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    cam.setLocation(new Vector3f(68.45442f, 8.235511f, 7.9676695f));
    cam.setRotation(new Quaternion(0.046916496f, -0.69500375f, 0.045538206f, 0.7160271f));


    flyCam.setMoveSpeed(50);

    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Texture diff = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg");
    diff.setWrap(Texture.WrapMode.Repeat);
    Texture norm = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall_normal.jpg");
    norm.setWrap(Texture.WrapMode.Repeat);
    mat.setTexture("DiffuseMap", diff);
    mat.setTexture("NormalMap", norm);
    mat.setFloat("Shininess", 2.0f);


    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(1.8f, 1.8f, 1.8f, 1.0f));

    rootNode.addLight(al);

    model = (Geometry) assetManager.loadModel("Models/Sponza/Sponza.j3o");
    model.getMesh().scaleTextureCoordinates(new Vector2f(2, 2));

    model.setMaterial(mat);

    rootNode.attachChild(model);

    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    SSAOFilter ssaoFilter = new SSAOFilter(12.940201f, 43.928635f, 0.32999992f, 0.6059958f);
    fpp.addFilter(ssaoFilter);
    SSAOUI ui = new SSAOUI(inputManager, ssaoFilter);

    viewPort.addProcessor(fpp);
}
 
Example #17
Source File: TestEnvironmentMapping.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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,
            SkyFactory.EnvMapType.CubeMap));

    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);
}
 
Example #18
Source File: TestHoverTank.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    Node tank = (Node) assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml");

    flyCam.setEnabled(false);
    ChaseCamera chaseCam = new ChaseCamera(cam, tank, inputManager);
    chaseCam.setSmoothMotion(true);
    chaseCam.setMaxDistance(100000);
    chaseCam.setMinVerticalRotation(-FastMath.PI / 2);
    viewPort.setBackgroundColor(ColorRGBA.DarkGray);

    Geometry tankGeom = (Geometry) tank.getChild(0);
    LodControl control = new LodControl();
    tankGeom.addControl(control);
    rootNode.attachChild(tank);

    Vector3f lightDir = new Vector3f(-0.8719428f, -0.46824604f, 0.14304268f);
    DirectionalLight dl = new DirectionalLight();
    dl.setColor(new ColorRGBA(1.0f, 0.92f, 0.75f, 1f));
    dl.setDirection(lightDir);

    Vector3f lightDir2 = new Vector3f(0.70518064f, 0.5902297f, -0.39287305f);
    DirectionalLight dl2 = new DirectionalLight();
    dl2.setColor(new ColorRGBA(0.7f, 0.85f, 1.0f, 1f));
    dl2.setDirection(lightDir2);

    rootNode.addLight(dl);
    rootNode.addLight(dl2);
    rootNode.attachChild(tank);

    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    BloomFilter bf = new BloomFilter(BloomFilter.GlowMode.Objects);
    bf.setBloomIntensity(2.0f);
    bf.setExposurePower(1.3f);
    fpp.addFilter(bf);
    BloomUI bui = new BloomUI(inputManager, bf);
    viewPort.addProcessor(fpp);
}
 
Example #19
Source File: TestCartoonEdge.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setupFilters(){
    if (renderer.getCaps().contains(Caps.GLSL100)){
        fpp=new FilterPostProcessor(assetManager);
        //fpp.setNumSamples(4);
        CartoonEdgeFilter toon=new CartoonEdgeFilter();
        toon.setEdgeColor(ColorRGBA.Yellow);
        fpp.addFilter(toon);
        viewPort.addProcessor(fpp);
    }
}
 
Example #20
Source File: TestEverything.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupHdr(){
    if (renderer.getCaps().contains(Caps.GLSL100)){
        toneMapFilter = new ToneMapFilter();
        toneMapFilter.setWhitePoint(new Vector3f(3f, 3f, 3f));
        FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
        fpp.addFilter(toneMapFilter);
        viewPort.addProcessor(fpp);

//        setPauseOnLostFocus(false);
    }
}
 
Example #21
Source File: TestFog.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void simpleInitApp() {
    this.flyCam.setMoveSpeed(10);
    Node mainScene=new Node();
    cam.setLocation(new Vector3f(-27.0f, 1.0f, 75.0f));
    cam.setRotation(new Quaternion(0.03f, 0.9f, 0f, 0.4f));

    // load sky
    mainScene.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));

    // create the geometry and attach it
    // load the level from zip or http zip
    if (useHttp) {
        assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/wildhouse.zip", HttpZipLocator.class.getName());
    } else {
        assetManager.registerLocator("wildhouse.zip", ZipLocator.class.getName());
    }
    Spatial scene = assetManager.loadModel("main.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);


    mainScene.attachChild(scene);
    rootNode.attachChild(mainScene);

    fpp=new FilterPostProcessor(assetManager);
    //fpp.setNumSamples(4);
    fog=new FogFilter();
    fog.setFogColor(new ColorRGBA(0.9f, 0.9f, 0.9f, 1.0f));
    fog.setFogDistance(155);
    fog.setFogDensity(2.0f);
    fpp.addFilter(fog);
    viewPort.addProcessor(fpp);
    initInputs();
}
 
Example #22
Source File: LightDrawer.java    From OpenRTS with MIT License 5 votes vote down vote up
public LightDrawer(MapView view, AssetManager am, Node rootNode, ViewPort vp) {
		this.view = view;
		this.rootNode = rootNode;

		FilterPostProcessor fpp = new FilterPostProcessor(am);

		int SHADOWMAP_SIZE = 4096;
//		sr = new DirectionalLightShadowRenderer(am, SHADOWMAP_SIZE, 1);
//		sr.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
//		sr.setShadowIntensity((float) ModelManager.getBattlefield().getSunLight().shadowCaster.intensity);
//		vp.addProcessor(sr);

		sf = new DirectionalLightShadowFilter(am, SHADOWMAP_SIZE, 1);
		sf.setEnabled(true);
		sf.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
		sf.setShadowZExtend(SHADOWMAP_SIZE);
		fpp.addFilter(sf);

		// Ambiant occlusion filter
		SSAOFilter ssaoFilter = new SSAOFilter(0.5f, 4f, 0.2f, 0.3f);
		// fpp.addFilter(ssaoFilter);
		// Glow filter
		BloomFilter bloom = new BloomFilter(BloomFilter.GlowMode.Objects);
		fpp.addFilter(bloom);
		vp.addProcessor(fpp);

	}
 
Example #23
Source File: TestCrossHatch.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@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));
    //cam.setFrustumFar(1000);


    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(new Vector3f(0, -13, 550), 800, 10, 700));
    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", false);
    sky.setCullHint(Spatial.CullHint.Never);
    rootNode.attachChild(sky);

    fpp=new FilterPostProcessor(assetManager);
    CrossHatchFilter chf=new CrossHatchFilter();
    
   

    viewPort.addProcessor(fpp);
    fpp.addFilter(chf);
    initInputs();

}
 
Example #24
Source File: TestTransparentCartoonEdge.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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);
        rootNode.attachChild(geom);

        // create the geometry and attach it
        Spatial teaGeom = assetManager.loadModel("Models/Tree/Tree2.mesh.xml");
        teaGeom.setQueueBucket(Bucket.Transparent);
        teaGeom.setShadowMode(ShadowMode.Cast);
        makeToonish(teaGeom);

        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);
        CartoonEdgeFilter toon=new CartoonEdgeFilter();
        toon.setEdgeWidth(0.5f);
        toon.setEdgeIntensity(1.0f);
        toon.setNormalThreshold(0.8f);
        fpp.addFilter(toon);
        viewPort.addProcessor(fpp);
    }
 
Example #25
Source File: FilterPostProcessorNode.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public FilterPostProcessor getFilterPostProcessor() {
    if (fpp == null) {
        this.fpp = dataObject.loadAsset();
    }
    return fpp;
}
 
Example #26
Source File: TestLightScattering.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
    public void simpleInitApp() {
        // put the camera in a bad position
        cam.setLocation(new Vector3f(55.35316f, -0.27061665f, 27.092093f));
        cam.setRotation(new Quaternion(0.010414706f, 0.9874893f, 0.13880467f, -0.07409228f));
//        cam.setDirection(new Vector3f(0,-0.5f,1.0f));
//        cam.setLocation(new Vector3f(0, 300, -500));
        //cam.setFrustumFar(1000);
        flyCam.setMoveSpeed(10);
        Material mat = assetManager.loadMaterial("Textures/Terrain/Rocky/Rocky.j3m");
        Spatial scene = assetManager.loadModel("Models/Terrain/Terrain.mesh.xml");
        TangentBinormalGenerator.generate(((Geometry)((Node)scene).getChild(0)).getMesh());
        scene.setMaterial(mat);
        scene.setShadowMode(ShadowMode.CastAndReceive);
        scene.setLocalScale(400);
        scene.setLocalTranslation(0, -10, -120);

        rootNode.attachChild(scene);

        // load sky
        rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/FullskiesBlueClear03.dds", false));

        DirectionalLight sun = new DirectionalLight();
        Vector3f lightDir = new Vector3f(-0.12f, -0.3729129f, 0.74847335f);
        sun.setDirection(lightDir);
        sun.setColor(ColorRGBA.White.clone().multLocal(2));
        scene.addLight(sun);

        PssmShadowRenderer pssmRenderer = new PssmShadowRenderer(assetManager,1024,4);
        pssmRenderer.setDirection(lightDir);
        pssmRenderer.setShadowIntensity(0.55f);
     //   viewPort.addProcessor(pssmRenderer);

        FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
//        SSAOFilter ssaoFilter= new SSAOFilter(viewPort, new SSAOConfig(0.36f,1.8f,0.84f,0.16f,false,true));
//        fpp.addFilter(ssaoFilter);


//           Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
//        mat2.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
//
//        Sphere lite=new Sphere(8, 8, 10.0f);
//        Geometry lightSphere=new Geometry("lightsphere", lite);
//        lightSphere.setMaterial(mat2);
        Vector3f lightPos = lightDir.multLocal(-3000);
//        lightSphere.setLocalTranslation(lightPos);
        // rootNode.attachChild(lightSphere);
        LightScatteringFilter filter = new LightScatteringFilter(lightPos);
        LightScatteringUI ui = new LightScatteringUI(inputManager, filter);
        fpp.addFilter(filter);
//fpp.setNumSamples(4);
        //fpp.addFilter(new RadialBlurFilter(0.3f,15.0f));
        //    SSAOUI ui=new SSAOUI(inputManager, ssaoFilter.getConfig());

        viewPort.addProcessor(fpp);
    }
 
Example #27
Source File: TestCinematic.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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(new Vector3f(0, -6.0f, 0), 50, 1, 50));
        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);
        }
    }
 
Example #28
Source File: TestBatchNodeTower.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    timer = new NanoTimer();
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
 //   bulletAppState.setEnabled(false);
    stateManager.attach(bulletAppState);
    bullet = new Sphere(32, 32, 0.4f, true, false);
    bullet.setTextureMode(TextureMode.Projected);
    bulletCollisionShape = new SphereCollisionShape(0.4f);

    brick = new Box(brickWidth, brickHeight, brickDepth);
    brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
    //bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    initMaterial();
    initTower();
    initFloor();
    initCrossHairs();
    this.cam.setLocation(new Vector3f(0, 25f, 8f));
    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
    cam.setFrustumFar(80);
    inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(actionListener, "shoot");
    rootNode.setShadowMode(ShadowMode.Off);
    
    batchNode.batch();
    batchNode.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(batchNode);
    
    
    shadowRenderer = new DirectionalLightShadowFilter(assetManager, 1024, 2);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    shadowRenderer.setLight(dl);
    shadowRenderer.setLambda(0.55f);
    shadowRenderer.setShadowIntensity(0.6f);
    shadowRenderer.setShadowCompareMode(CompareMode.Hardware);
    shadowRenderer.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(shadowRenderer);
    viewPort.addProcessor(fpp);   
}
 
Example #29
Source File: DesktopAssetManager.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public FilterPostProcessor loadFilter(String name){
    return loadFilter(new FilterKey(name));
}
 
Example #30
Source File: DesktopAssetManager.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public FilterPostProcessor loadFilter(FilterKey key){
    return loadAsset(key);
}