• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package jme3test.post;
2 
3 import com.jme3.app.SimpleApplication;
4 import com.jme3.light.AmbientLight;
5 import com.jme3.light.DirectionalLight;
6 import com.jme3.material.Material;
7 import com.jme3.math.*;
8 import com.jme3.post.FilterPostProcessor;
9 import com.jme3.post.ssao.SSAOFilter;
10 import com.jme3.renderer.queue.RenderQueue.Bucket;
11 import com.jme3.renderer.queue.RenderQueue.ShadowMode;
12 import com.jme3.scene.Geometry;
13 import com.jme3.scene.Spatial;
14 import com.jme3.scene.shape.Quad;
15 
16 public class TestTransparentSSAO extends SimpleApplication {
17 
main(String[] args)18     public static void main(String[] args) {
19         TestTransparentSSAO app = new TestTransparentSSAO();
20         app.start();
21     }
22 
simpleInitApp()23     public void simpleInitApp() {
24         renderManager.setAlphaToCoverage(true);
25         cam.setLocation(new Vector3f(0.14914267f, 0.58147097f, 4.7686534f));
26         cam.setRotation(new Quaternion(-0.0044764364f, 0.9767943f, 0.21314798f, 0.020512417f));
27 
28 //        cam.setLocation(new Vector3f(2.0606942f, 3.20342f, 6.7860126f));
29 //        cam.setRotation(new Quaternion(-0.017481906f, 0.98241085f, -0.12393151f, -0.13857932f));
30 
31         viewPort.setBackgroundColor(ColorRGBA.DarkGray);
32 
33         Quad q = new Quad(20, 20);
34         q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(5));
35         Geometry geom = new Geometry("floor", q);
36         Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
37         geom.setMaterial(mat);
38 
39         geom.rotate(-FastMath.HALF_PI, 0, 0);
40         geom.center();
41         geom.setShadowMode(ShadowMode.Receive);
42         rootNode.attachChild(geom);
43 
44         // create the geometry and attach it
45         Spatial teaGeom = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
46         teaGeom.setQueueBucket(Bucket.Transparent);
47         teaGeom.setShadowMode(ShadowMode.Cast);
48 
49         AmbientLight al = new AmbientLight();
50         al.setColor(ColorRGBA.White.mult(2));
51         rootNode.addLight(al);
52 
53         DirectionalLight dl1 = new DirectionalLight();
54         dl1.setDirection(new Vector3f(1, -1, 1).normalizeLocal());
55         dl1.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
56         rootNode.addLight(dl1);
57 
58         DirectionalLight dl = new DirectionalLight();
59         dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
60         dl.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
61         rootNode.addLight(dl);
62 
63         rootNode.attachChild(teaGeom);
64 
65         FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
66 
67         SSAOFilter ssao = new SSAOFilter(0.49997783f, 42.598858f, 35.999966f, 0.39299846f);
68         fpp.addFilter(ssao);
69 
70         SSAOUI ui = new SSAOUI(inputManager, ssao);
71 
72         viewPort.addProcessor(fpp);
73     }
74 }
75