Search in sources :

Example 31 with FilterPostProcessor

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

the class TestSSAO2 method simpleInitApp.

@Override
public void simpleInitApp() {
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    rootNode.addLight(dl);
    flyCam.setDragToRotate(true);
    setPauseOnLostFocus(false);
    getStateManager().attach(new DetailedProfilerState());
    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat.setFloat("Shininess", 16f);
    //mat.setBoolean("VertexLighting", true);
    Geometry floor = new Geometry("floor", new Box(1000, 0.1f, 1000));
    floor.setMaterial(mat);
    rootNode.attachChild(floor);
    Node teapotNode = (Node) assetManager.loadModel("Models/Teapot/Teapot.mesh.xml");
    Geometry teapot = (Geometry) teapotNode.getChild(0);
    teapot.setMaterial(mat);
    //Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
    for (int f = 10; f > 3; f--) {
        for (int y = -f; y < f; y++) {
            for (int x = -f; x < f; x++) {
                Geometry clonePot = teapot.clone();
                //clonePot.setMaterial(mat);
                clonePot.setLocalTranslation(x * .5f, 10 - f, y * .5f);
                clonePot.setLocalScale(.15f);
                rootNode.attachChild(clonePot);
            }
        }
    }
    cam.setLocation(new Vector3f(10.247649f, 8.275992f, 10.405156f));
    cam.setRotation(new Quaternion(-0.083419204f, 0.90370524f, -0.20599906f, -0.36595422f));
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    SSAOFilter ssaoFilter = new SSAOFilter(2.9299974f, 25f, 5.8100376f, 0.091000035f);
    int numSamples = context.getSettings().getSamples();
    if (numSamples > 0) {
        fpp.setNumSamples(numSamples);
    }
    //ssaoFilter.setApproximateNormals(true);
    fpp.addFilter(ssaoFilter);
    SSAOUI ui = new SSAOUI(inputManager, ssaoFilter);
    viewPort.addProcessor(fpp);
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) DetailedProfilerState(com.jme3.app.DetailedProfilerState) Material(com.jme3.material.Material) Box(com.jme3.scene.shape.Box) FilterPostProcessor(com.jme3.post.FilterPostProcessor)

Example 32 with FilterPostProcessor

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

the class TestBloom 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));
    //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(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", false);
    sky.setCullHint(Spatial.CullHint.Never);
    rootNode.attachChild(sky);
    fpp = new FilterPostProcessor(assetManager);
    // fpp.setNumSamples(4);
    int numSamples = getContext().getSettings().getSamples();
    if (numSamples > 0) {
        fpp.setNumSamples(numSamples);
    }
    BloomFilter bloom = new BloomFilter();
    bloom.setDownSamplingFactor(2);
    bloom.setBlurScale(1.37f);
    bloom.setExposurePower(3.30f);
    bloom.setExposureCutOff(0.2f);
    bloom.setBloomIntensity(2.45f);
    BloomUI ui = new BloomUI(inputManager, bloom);
    viewPort.addProcessor(fpp);
    fpp.addFilter(bloom);
    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) BloomFilter(com.jme3.post.filters.BloomFilter)

Example 33 with FilterPostProcessor

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

the class TestCartoonEdge method setupFilters.

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);
    }
}
Also used : FilterPostProcessor(com.jme3.post.FilterPostProcessor) CullHint(com.jme3.scene.Spatial.CullHint) CartoonEdgeFilter(com.jme3.post.filters.CartoonEdgeFilter)

Example 34 with FilterPostProcessor

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

the class TestCrossHatch 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));
    //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(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", false);
    sky.setCullHint(Spatial.CullHint.Never);
    rootNode.attachChild(sky);
    fpp = new FilterPostProcessor(assetManager);
    int numSamples = getContext().getSettings().getSamples();
    if (numSamples > 0) {
        fpp.setNumSamples(numSamples);
    }
    CrossHatchFilter chf = new CrossHatchFilter();
    viewPort.addProcessor(fpp);
    fpp.addFilter(chf);
    initInputs();
}
Also used : Geometry(com.jme3.scene.Geometry) CrossHatchFilter(com.jme3.post.filters.CrossHatchFilter) 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)

Example 35 with FilterPostProcessor

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

the class TestSkeletonControlRefresh method simpleInitApp.

@Override
public void simpleInitApp() {
    viewPort.setBackgroundColor(ColorRGBA.White);
    flyCam.setMoveSpeed(10f);
    cam.setLocation(new Vector3f(3.8664846f, 6.2704787f, 9.664585f));
    cam.setRotation(new Quaternion(-0.054774776f, 0.94064945f, -0.27974048f, -0.18418397f));
    makeHudText();
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal());
    dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
    rootNode.addLight(dl);
    Material m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    TextureKey k = new TextureKey("Models/Oto/Oto.jpg", false);
    m.setTexture("ColorMap", assetManager.loadTexture(k));
    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE; j++) {
            Spatial model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
            //setting a different material
            model.setMaterial(m.clone());
            model.setLocalScale(0.1f);
            model.setLocalTranslation(i - SIZE / 2, 0, j - SIZE / 2);
            control = model.getControl(AnimControl.class);
            channel = control.createChannel();
            channel.setAnim(animNames[(i + j) % 4]);
            channel.setLoopMode(LoopMode.DontLoop);
            SkeletonControl skeletonControl = model.getControl(SkeletonControl.class);
            //This is a workaround the issue. this call will make the SkeletonControl gather the targets again.
            //skeletonControl.setSpatial(model);
            skeletonControl.setHardwareSkinningPreferred(hwSkinningEnable);
            skControls.add(skeletonControl);
            rootNode.attachChild(model);
        }
    }
    rootNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
    setupFloor();
    inputManager.addListener(this, "toggleHWS");
    inputManager.addMapping("toggleHWS", new KeyTrigger(KeyInput.KEY_SPACE));
    //        DirectionalLightShadowRenderer pssm = new DirectionalLightShadowRenderer(assetManager, 1024, 2);
    //        pssm.setLight(dl);
    //        viewPort.addProcessor(pssm);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    DirectionalLightShadowFilter sf = new DirectionalLightShadowFilter(assetManager, 1024, 2);
    sf.setLight(dl);
    fpp.addFilter(sf);
    fpp.addFilter(new SSAOFilter());
    viewPort.addProcessor(fpp);
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) Quaternion(com.jme3.math.Quaternion) KeyTrigger(com.jme3.input.controls.KeyTrigger) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) DirectionalLightShadowFilter(com.jme3.shadow.DirectionalLightShadowFilter) TextureKey(com.jme3.asset.TextureKey) ColorRGBA(com.jme3.math.ColorRGBA) Spatial(com.jme3.scene.Spatial) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight)

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