use of com.jme3.post.ssao.SSAOFilter in project TeachingInSimulation by ScOrPiOzzy.
the class JmeApplication method simpleInitApp.
@Override
public void simpleInitApp() {
super.simpleInitApp();
stateManager.attach(new MouseEventState());
stateManager.detach(stateManager.getState(FlyCamAppState.class));
renderer.setMainFrameBufferSrgb(true);
// String assetPath = SpringUtil.getBean(HTTPUtils.class).getFullPath("assets/");
// LOG.debug("注册资源路径:{}", assetPath); // http://192.168.x.x:port/***/assests/
// // 注册资源路径
// assetManager.registerLocator(assetPath, UrlLocator.class);
assetManager.registerLocator("assets", FileLocator.class);
cam.setFrustumPerspective(45, (float) cam.getWidth() / cam.getHeight(), 0.01f, 100f);
// // 创建天空盒
// // Spatial sky = SkyFactory.createSky(assetManager, "Model/Sky/noon_grass_2k.hdr", SkyFactory.EnvMapType.EquirectMap);
// Spatial sky = SkyFactory.createSky(assetManager, "Model/Sky/Path.hdr", SkyFactory.EnvMapType.EquirectMap);
// rootNode.attachChild(sky);
//
// 滤镜
// fpp.addFilter(new FXAAFilter());
// postProcessor.addFilter(new ToneMapFilter(Vector3f.UNIT_XYZ.mult(4.0f)));
// fpp.addFilter(new SSAOFilter(0.5f, 3, 0.2f, 0.2f));
}
use of com.jme3.post.ssao.SSAOFilter in project TeachingInSimulation by ScOrPiOzzy.
the class TestPBRLighting method simpleInitApp.
@Override
public void simpleInitApp() {
assetManager.registerLoader(KTXLoader.class, "ktx");
viewPort.setBackgroundColor(ColorRGBA.White);
modelNode = (Node) new Node("modelNode");
model = (Geometry) assetManager.loadModel("Models/Tank/tank.j3o");
MikktspaceTangentGenerator.generate(model);
modelNode.attachChild(model);
dl = new DirectionalLight();
dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
rootNode.addLight(dl);
dl.setColor(ColorRGBA.White);
rootNode.attachChild(modelNode);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
// fpp.addFilter(new FXAAFilter());
fpp.addFilter(new ToneMapFilter(Vector3f.UNIT_XYZ.mult(4.0f)));
// fpp.addFilter(new SSAOFilter(0.5f, 3, 0.2f, 0.2f));
viewPort.addProcessor(fpp);
// Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Sky_Cloudy.hdr", SkyFactory.EnvMapType.EquirectMap);
Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Path.hdr", SkyFactory.EnvMapType.EquirectMap);
// Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", SkyFactory.EnvMapType.CubeMap);
// Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/road.hdr", SkyFactory.EnvMapType.EquirectMap);
rootNode.attachChild(sky);
pbrMat = assetManager.loadMaterial("Models/Tank/tank.j3m");
model.setMaterial(pbrMat);
final EnvironmentCamera envCam = new EnvironmentCamera(256, new Vector3f(0, 3f, 0));
stateManager.attach(envCam);
// EnvironmentManager envManager = new EnvironmentManager();
// stateManager.attach(envManager);
// envManager.setScene(rootNode);
// LightsDebugState debugState = new LightsDebugState();
// stateManager.attach(debugState);
ChaseCamera chaser = new ChaseCamera(cam, modelNode, inputManager);
chaser.setDragToRotate(true);
chaser.setMinVerticalRotation(-FastMath.HALF_PI);
chaser.setMaxDistance(1000);
chaser.setSmoothMotion(true);
chaser.setRotationSensitivity(10);
chaser.setZoomSensitivity(5);
flyCam.setEnabled(false);
// flyCam.setMoveSpeed(100);
// inputManager.addListener(new ActionListener() {
// @Override
// public void onAction(String name, boolean isPressed, float tpf) {
// // if (name.equals("debug") && isPressed) {
// // if (tex == null) {
// // return;
// // }
// // if (tex.getParent() == null) {
// // guiNode.attachChild(tex);
// // } else {
// // tex.removeFromParent();
// // }
// // }
//
// if (name.equals("rup") && isPressed) {
// roughness = FastMath.clamp(roughness + 0.1f, 0.0f, 1.0f);
// pbrMat.setFloat("Roughness", roughness);
// }
// if (name.equals("rdown") && isPressed) {
// roughness = FastMath.clamp(roughness - 0.1f, 0.0f, 1.0f);
// pbrMat.setFloat("Roughness", roughness);
// }
//
//
// if (name.equals("up") && isPressed) {
// model.move(0, tpf * 100f, 0);
// }
//
// if (name.equals("down") && isPressed) {
// model.move(0, -tpf * 100f, 0);
// }
// if (name.equals("left") && isPressed) {
// model.move(0, 0, tpf * 100f);
// }
// if (name.equals("right") && isPressed) {
// model.move(0, 0, -tpf * 100f);
// }
// if (name.equals("light") && isPressed) {
// dl.setDirection(cam.getDirection().normalize());
// }
// }
// }, "toggle", "light", "up", "down", "left", "right", "debug", "rup", "rdown");
//
// inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_RETURN));
// inputManager.addMapping("light", new KeyTrigger(KeyInput.KEY_F));
// inputManager.addMapping("up", new KeyTrigger(KeyInput.KEY_UP));
// inputManager.addMapping("down", new KeyTrigger(KeyInput.KEY_DOWN));
// inputManager.addMapping("left", new KeyTrigger(KeyInput.KEY_LEFT));
// inputManager.addMapping("right", new KeyTrigger(KeyInput.KEY_RIGHT));
// inputManager.addMapping("debug", new KeyTrigger(KeyInput.KEY_D));
// inputManager.addMapping("rup", new KeyTrigger(KeyInput.KEY_T));
// inputManager.addMapping("rdown", new KeyTrigger(KeyInput.KEY_G));
// MaterialDebugAppState debug = new MaterialDebugAppState();
// debug.registerBinding("Common/MatDefs/Light/PBRLighting.frag", rootNode);
// debug.registerBinding("Common/ShaderLib/PBR.glsllib", rootNode);
// getStateManager().attach(debug);
}
use of com.jme3.post.ssao.SSAOFilter in project jmonkeyengine by jMonkeyEngine.
the class TestPBRLighting method simpleInitApp.
@Override
public void simpleInitApp() {
assetManager.registerLoader(KTXLoader.class, "ktx");
viewPort.setBackgroundColor(ColorRGBA.White);
modelNode = (Node) new Node("modelNode");
model = (Geometry) assetManager.loadModel("Models/Tank/tank.j3o");
MikktspaceTangentGenerator.generate(model);
modelNode.attachChild(model);
dl = new DirectionalLight();
dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
rootNode.addLight(dl);
dl.setColor(ColorRGBA.White);
rootNode.attachChild(modelNode);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
// fpp.addFilter(new FXAAFilter());
fpp.addFilter(new ToneMapFilter(Vector3f.UNIT_XYZ.mult(4.0f)));
// fpp.addFilter(new SSAOFilter(0.5f, 3, 0.2f, 0.2f));
viewPort.addProcessor(fpp);
//Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Sky_Cloudy.hdr", SkyFactory.EnvMapType.EquirectMap);
Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Path.hdr", SkyFactory.EnvMapType.EquirectMap);
//Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", SkyFactory.EnvMapType.CubeMap);
//Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/road.hdr", SkyFactory.EnvMapType.EquirectMap);
rootNode.attachChild(sky);
pbrMat = assetManager.loadMaterial("Models/Tank/tank.j3m");
model.setMaterial(pbrMat);
final EnvironmentCamera envCam = new EnvironmentCamera(128, new Vector3f(0, 3f, 0));
stateManager.attach(envCam);
// EnvironmentManager envManager = new EnvironmentManager();
// stateManager.attach(envManager);
// envManager.setScene(rootNode);
LightsDebugState debugState = new LightsDebugState();
stateManager.attach(debugState);
ChaseCamera chaser = new ChaseCamera(cam, modelNode, inputManager);
chaser.setDragToRotate(true);
chaser.setMinVerticalRotation(-FastMath.HALF_PI);
chaser.setMaxDistance(1000);
chaser.setSmoothMotion(true);
chaser.setRotationSensitivity(10);
chaser.setZoomSensitivity(5);
flyCam.setEnabled(false);
//flyCam.setMoveSpeed(100);
inputManager.addListener(new ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("debug") && isPressed) {
if (tex == null) {
return;
}
if (tex.getParent() == null && tex2.getParent() == null) {
guiNode.attachChild(tex);
} else if (tex2.getParent() == null) {
tex.removeFromParent();
guiNode.attachChild(tex2);
} else {
tex2.removeFromParent();
}
}
if (name.equals("up") && isPressed) {
model.move(0, tpf * 100f, 0);
}
if (name.equals("down") && isPressed) {
model.move(0, -tpf * 100f, 0);
}
if (name.equals("left") && isPressed) {
model.move(0, 0, tpf * 100f);
}
if (name.equals("right") && isPressed) {
model.move(0, 0, -tpf * 100f);
}
if (name.equals("light") && isPressed) {
dl.setDirection(cam.getDirection().normalize());
}
}
}, "toggle", "light", "up", "down", "left", "right", "debug");
inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_RETURN));
inputManager.addMapping("light", new KeyTrigger(KeyInput.KEY_F));
inputManager.addMapping("up", new KeyTrigger(KeyInput.KEY_UP));
inputManager.addMapping("down", new KeyTrigger(KeyInput.KEY_DOWN));
inputManager.addMapping("left", new KeyTrigger(KeyInput.KEY_LEFT));
inputManager.addMapping("right", new KeyTrigger(KeyInput.KEY_RIGHT));
inputManager.addMapping("debug", new KeyTrigger(KeyInput.KEY_D));
MaterialDebugAppState debug = new MaterialDebugAppState();
debug.registerBinding("Common/MatDefs/Light/PBRLighting.frag", rootNode);
getStateManager().attach(debug);
}
use of com.jme3.post.ssao.SSAOFilter in project jmonkeyengine by jMonkeyEngine.
the class TestSSAO method simpleInitApp.
@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);
}
use of com.jme3.post.ssao.SSAOFilter 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);
}
Aggregations