com.jme3.post.ssao.SSAOFilter Java Examples
The following examples show how to use
com.jme3.post.ssao.SSAOFilter.
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: JmeSSAOFilter.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override protected Sheet createSheet() { Sheet sheet = super.createSheet(); Sheet.Set set = Sheet.createPropertiesSet(); set.setDisplayName("SSAO"); set.setName("SSAO"); SSAOFilter obj = (SSAOFilter) filter; if (obj == null) { return sheet; } createFields(SSAOFilter.class, set, obj); sheet.put(set); return sheet; }
Example #2
Source File: TestJaime.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 #3
Source File: TestSSAO.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@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 #4
Source File: FilterUtil.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static SSAOFilter cloneSSAOFilter(SSAOFilter filter){ SSAOFilter clone = new SSAOFilter(); clone.setSampleRadius(filter.getSampleRadius()); clone.setIntensity(filter.getIntensity()); clone.setScale(filter.getScale()); clone.setBias(filter.getBias()); return clone; }
Example #5
Source File: TestSSAO.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@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 #6
Source File: LightDrawer.java From OpenRTS with MIT License | 5 votes |
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 #7
Source File: JmeSSAOFilter.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Node[] createNodes(Object key, DataObject dataObject, boolean readOnly) { return new Node[]{new JmeSSAOFilter((SSAOFilter) key, dataObject, readOnly)}; }
Example #8
Source File: JmeSSAOFilter.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override public Class<?> getExplorerObjectClass() { return SSAOFilter.class; }
Example #9
Source File: JmeSSAOFilter.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public JmeSSAOFilter(SSAOFilter filter, DataObject object, boolean readOnly) { super(filter); this.dataObject = object; this.readOnly = readOnly; }
Example #10
Source File: NewSSAOFilterAction.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override protected Filter doCreateFilter() { return new SSAOFilter(); }
Example #11
Source File: TestTransparentSSAO.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
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); 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); SSAOFilter ssao = new SSAOFilter(0.49997783f, 42.598858f, 35.999966f, 0.39299846f); fpp.addFilter(ssao); SSAOUI ui = new SSAOUI(inputManager, ssao); viewPort.addProcessor(fpp); }
Example #12
Source File: TestMultiplesFilters.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
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)); // 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(); 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)); }
Example #13
Source File: SSAOUI.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public SSAOUI(InputManager inputManager, SSAOFilter filter) { this.filter = filter; init(inputManager); }
Example #14
Source File: AbstractVRViewManager.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Sets the two views to use the list of {@link SceneProcessor processors}. * @param sourceViewport the {@link ViewPort viewport} that contains the processors to use. */ public void syncScreenProcessing(ViewPort sourceViewport) { if (environment != null){ if( getRightViewPort() == null ){ return; } if (environment.getApplication() != null){ // setup post processing filters if( getRightPostProcessor() == null ) { rightPostProcessor = new FilterPostProcessor(environment.getApplication().getAssetManager()); leftPostProcessor = new FilterPostProcessor(environment.getApplication().getAssetManager()); } // clear out all filters & processors, to start from scratch getRightPostProcessor().removeAllFilters(); getLeftPostProcessor().removeAllFilters(); getLeftViewPort().clearProcessors(); getRightViewPort().clearProcessors(); // if we have no processors to sync, don't add the FilterPostProcessor if( sourceViewport.getProcessors().isEmpty() ) return; // add post processors we just made, which are empty getLeftViewPort().addProcessor(getLeftPostProcessor()); getRightViewPort().addProcessor(getRightPostProcessor()); // go through all of the filters in the processors list // add them to the left viewport processor & clone them to the right for(SceneProcessor sceneProcessor : sourceViewport.getProcessors()) { if (sceneProcessor instanceof FilterPostProcessor) { for(Filter f : ((FilterPostProcessor)sceneProcessor).getFilterList() ) { if( f instanceof TranslucentBucketFilter ) { // just remove this filter, we will add it at the end manually ((FilterPostProcessor)sceneProcessor).removeFilter(f); } else { getLeftPostProcessor().addFilter(f); // clone to the right Filter f2; if(f instanceof FogFilter){ f2 = FilterUtil.cloneFogFilter((FogFilter)f); } else if (f instanceof CartoonSSAO ) { f2 = new CartoonSSAO((CartoonSSAO)f); } else if (f instanceof SSAOFilter){ f2 = FilterUtil.cloneSSAOFilter((SSAOFilter)f); } else if (f instanceof DirectionalLightShadowFilter){ f2 = FilterUtil.cloneDirectionalLightShadowFilter(environment.getApplication().getAssetManager(), (DirectionalLightShadowFilter)f); } else { f2 = f; // dof, bloom, lightscattering etc. } getRightPostProcessor().addFilter(f2); } } } else if (sceneProcessor instanceof VRDirectionalLightShadowRenderer) { // shadow processing // TODO: make right shadow processor use same left shadow maps for performance VRDirectionalLightShadowRenderer dlsr = (VRDirectionalLightShadowRenderer) sceneProcessor; VRDirectionalLightShadowRenderer dlsrRight = dlsr.clone(); dlsrRight.setLight(dlsr.getLight()); getRightViewPort().getProcessors().add(0, dlsrRight); getLeftViewPort().getProcessors().add(0, sceneProcessor); } } // make sure each has a translucent filter renderer getLeftPostProcessor().addFilter(new TranslucentBucketFilter()); getRightPostProcessor().addFilter(new TranslucentBucketFilter()); } else { throw new IllegalStateException("The VR environment is not attached to any application."); } } else { throw new IllegalStateException("This VR view manager is not attached to any VR environment."); } }
Example #15
Source File: TestSkeletonControlRefresh.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@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 = 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); animComposer = model.getControl(AnimComposer.class); for (AnimClip animClip : animComposer.getAnimClips()) { Action action = animComposer.action(animClip.getName()); animComposer.addAction(animClip.getName(), new BaseAction( Tweens.sequence(action, Tweens.callMethod(animComposer, "removeCurrentAction", AnimComposer.DEFAULT_LAYER)))); } animComposer.setCurrentAction(new ArrayList<>(animComposer.getAnimClips()).get((i + j) % 4).getName()); SkinningControl skinningControl = model.getControl(SkinningControl.class); skinningControl.setHardwareSkinningPreferred(hwSkinningEnable); skinningControls.add(skinningControl); 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); }
Example #16
Source File: TestTransparentSSAO.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override 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); SSAOFilter ssao = new SSAOFilter();//0.49997783f, 42.598858f, 35.999966f, 0.39299846f fpp.addFilter(ssao); SSAOUI ui = new SSAOUI(inputManager, ssao); viewPort.addProcessor(fpp); }
Example #17
Source File: TestMultiplesFilters.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void simpleInitApp() { File file = new File("wildhouse.zip"); if (!file.exists()) { useHttp = true; } 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", SkyFactory.EnvMapType.CubeMap)); // create the geometry and attach it // load the level from zip or http zip if (useHttp) { assetManager.registerLocator( "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jmonkeyengine/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() { @Override 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)); }
Example #18
Source File: TestSSAO2.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@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); // Sphere sph = new Sphere(16, 16, 4); // Geometry teapot = new Geometry("teapot", sph); // show normals as material //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); }
Example #19
Source File: SSAOUI.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
public SSAOUI(InputManager inputManager, SSAOFilter filter) { this.filter = filter; init(inputManager); }