use of com.jme3.post.filters.BloomFilter in project jmonkeyengine by jMonkeyEngine.
the class TestPbrEnv method simpleInitApp.
@Override
public void simpleInitApp() {
assetManager.registerLoader(KTXLoader.class, "ktx");
// put the camera in a bad position
cam.setLocation(new Vector3f(-52.433647f, 68.69636f, -118.60924f));
cam.setRotation(new Quaternion(0.10294232f, 0.25269797f, -0.027049713f, 0.96167296f));
flyCam.setMoveSpeed(100);
loadScene();
dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 4);
dlsr.setLight(l);
//dlsr.setLambda(0.55f);
dlsr.setShadowIntensity(0.5f);
dlsr.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
//dlsr.displayDebug();
// viewPort.addProcessor(dlsr);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
fpp.addFilter(new ToneMapFilter(Vector3f.UNIT_XYZ.mult(6.0f)));
SSAOFilter ssao = new SSAOFilter();
ssao.setIntensity(5);
fpp.addFilter(ssao);
BloomFilter bloomFilter = new BloomFilter();
fpp.addFilter(bloomFilter);
fpp.addFilter(new FXAAFilter());
//viewPort.addProcessor(fpp);
initInputs();
// envManager = new EnvironmentManager();
// getStateManager().attach(envManager);
//
envCam = new EnvironmentCamera();
getStateManager().attach(envCam);
debugState = new LightsDebugState();
debugState.setProbeScale(5);
getStateManager().attach(debugState);
camGeom = new Geometry("camGeom", new Sphere(16, 16, 2));
// Material m = new Material(assetManager, "Common/MatDefs/Misc/UnshadedNodes.j3md");
// m.setColor("Color", ColorRGBA.Green);
Material m = assetManager.loadMaterial("jme3test/light/pbr/pbrMat3.j3m");
camGeom.setMaterial(m);
camGeom.setLocalTranslation(0, 20, 0);
camGeom.setLocalScale(5);
rootNode.attachChild(camGeom);
// envManager.setScene(rootNode);
// MaterialDebugAppState debug = new MaterialDebugAppState();
// debug.registerBinding("MatDefs/PBRLighting.frag", rootNode);
// getStateManager().attach(debug);
flyCam.setDragToRotate(true);
setPauseOnLostFocus(false);
// cam.lookAt(camGeom.getWorldTranslation(), Vector3f.UNIT_Y);
}
use of com.jme3.post.filters.BloomFilter in project jmonkeyengine by jMonkeyEngine.
the class TestWalkingChar method setupFilter.
private void setupFilter() {
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
BloomFilter bloom = new BloomFilter(BloomFilter.GlowMode.Objects);
fpp.addFilter(bloom);
viewPort.addProcessor(fpp);
}
use of com.jme3.post.filters.BloomFilter in project jmonkeyengine by jMonkeyEngine.
the class TestBatchNodeCluster method simpleInitApp.
//protected
// protected Geometry player;
@Override
public void simpleInitApp() {
timer = new NanoTimer();
batchNode = new SimpleBatchNode("BatchNode");
xPosition.add(0);
yPosition.add(0);
zPosition.add(0);
mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat1.setColor("Color", ColorRGBA.White);
mat1.setColor("GlowColor", ColorRGBA.Blue.mult(10));
mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat2.setColor("Color", ColorRGBA.White);
mat2.setColor("GlowColor", ColorRGBA.Red.mult(10));
mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat3.setColor("Color", ColorRGBA.White);
mat3.setColor("GlowColor", ColorRGBA.Yellow.mult(10));
mat4 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat4.setColor("Color", ColorRGBA.White);
mat4.setColor("GlowColor", ColorRGBA.Orange.mult(10));
randomGenerator();
//rootNode.attachChild(SkyFactory.createSky(
// assetManager, "Textures/SKY02.zip", false));
inputManager.addMapping("Start Game", new KeyTrigger(KeyInput.KEY_J));
inputManager.addListener(al, new String[] { "Start Game" });
cam.setLocation(new Vector3f(-34.403286f, 126.65158f, 434.791f));
cam.setRotation(new Quaternion(0.022630932f, 0.9749435f, -0.18736298f, 0.11776358f));
batchNode.batch();
terrain = new Node("terrain");
terrain.setLocalTranslation(50, 0, 50);
terrain.attachChild(batchNode);
flyCam.setMoveSpeed(100);
rootNode.attachChild(terrain);
Vector3f pos = new Vector3f(-40, 0, -40);
batchNode.setLocalTranslation(pos);
Arrow a = new Arrow(new Vector3f(0, 50, 0));
Geometry g = new Geometry("a", a);
g.setLocalTranslation(terrain.getLocalTranslation());
Material m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
m.setColor("Color", ColorRGBA.Blue);
g.setMaterial(m);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
fpp.addFilter(new BloomFilter(BloomFilter.GlowMode.Objects));
// SSAOFilter ssao = new SSAOFilter(8.630104f,22.970434f,2.9299977f,0.2999997f);
// fpp.addFilter(ssao);
viewPort.addProcessor(fpp);
// viewPort.setBackgroundColor(ColorRGBA.DarkGray);
}
use of com.jme3.post.filters.BloomFilter 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();
}
use of com.jme3.post.filters.BloomFilter in project jmonkeyengine by jMonkeyEngine.
the class TestPostWater method simpleInitApp.
@Override
public void simpleInitApp() {
setDisplayFps(false);
setDisplayStatView(false);
Node mainScene = new Node("Main Scene");
rootNode.attachChild(mainScene);
createTerrain(mainScene);
DirectionalLight sun = new DirectionalLight();
sun.setDirection(lightDir);
sun.setColor(ColorRGBA.White.clone().multLocal(1f));
mainScene.addLight(sun);
AmbientLight al = new AmbientLight();
al.setColor(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f));
mainScene.addLight(al);
flyCam.setMoveSpeed(50);
//cam.setLocation(new Vector3f(-700, 100, 300));
//cam.setRotation(new Quaternion().fromAngleAxis(0.5f, Vector3f.UNIT_Z));
// cam.setLocation(new Vector3f(-327.21957f, 61.6459f, 126.884346f));
// cam.setRotation(new Quaternion(0.052168474f, 0.9443102f, -0.18395276f, 0.2678024f));
cam.setLocation(new Vector3f(-370.31592f, 182.04016f, 196.81192f));
cam.setRotation(new Quaternion(0.015302252f, 0.9304095f, -0.039101653f, 0.3641086f));
Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", false);
sky.setLocalScale(350);
mainScene.attachChild(sky);
cam.setFrustumFar(4000);
//Water Filter
water = new WaterFilter(rootNode, lightDir);
water.setWaterColor(new ColorRGBA().setAsSrgb(0.0078f, 0.3176f, 0.5f, 1.0f));
water.setDeepWaterColor(new ColorRGBA().setAsSrgb(0.0039f, 0.00196f, 0.145f, 1.0f));
water.setUnderWaterFogDistance(80);
water.setWaterTransparency(0.12f);
water.setFoamIntensity(0.4f);
water.setFoamHardness(0.3f);
water.setFoamExistence(new Vector3f(0.8f, 8f, 1f));
water.setReflectionDisplace(50);
water.setRefractionConstant(0.25f);
water.setColorExtinction(new Vector3f(30, 50, 70));
water.setCausticsIntensity(0.4f);
water.setWaveScale(0.003f);
water.setMaxAmplitude(2f);
water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
water.setRefractionStrength(0.2f);
water.setWaterHeight(initialWaterHeight);
//Bloom Filter
BloomFilter bloom = new BloomFilter();
bloom.setExposurePower(55);
bloom.setBloomIntensity(1.0f);
//Light Scattering Filter
LightScatteringFilter lsf = new LightScatteringFilter(lightDir.mult(-300));
lsf.setLightDensity(0.5f);
//Depth of field Filter
DepthOfFieldFilter dof = new DepthOfFieldFilter();
dof.setFocusDistance(0);
dof.setFocusRange(100);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
fpp.addFilter(water);
fpp.addFilter(bloom);
fpp.addFilter(dof);
fpp.addFilter(lsf);
fpp.addFilter(new FXAAFilter());
// fpp.addFilter(new TranslucentBucketFilter());
int numSamples = getContext().getSettings().getSamples();
if (numSamples > 0) {
fpp.setNumSamples(numSamples);
}
uw = cam.getLocation().y < waterHeight;
waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", false);
waves.setLooping(true);
waves.setReverbEnabled(true);
if (uw) {
waves.setDryFilter(new LowPassFilter(0.5f, 0.1f));
} else {
waves.setDryFilter(aboveWaterAudioFilter);
}
audioRenderer.playSource(waves);
//
viewPort.addProcessor(fpp);
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if (isPressed) {
if (name.equals("foam1")) {
water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam.jpg"));
}
if (name.equals("foam2")) {
water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
}
if (name.equals("foam3")) {
water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam3.jpg"));
}
if (name.equals("upRM")) {
water.setReflectionMapSize(Math.min(water.getReflectionMapSize() * 2, 4096));
System.out.println("Reflection map size : " + water.getReflectionMapSize());
}
if (name.equals("downRM")) {
water.setReflectionMapSize(Math.max(water.getReflectionMapSize() / 2, 32));
System.out.println("Reflection map size : " + water.getReflectionMapSize());
}
}
}
}, "foam1", "foam2", "foam3", "upRM", "downRM");
inputManager.addMapping("foam1", new KeyTrigger(KeyInput.KEY_1));
inputManager.addMapping("foam2", new KeyTrigger(KeyInput.KEY_2));
inputManager.addMapping("foam3", new KeyTrigger(KeyInput.KEY_3));
inputManager.addMapping("upRM", new KeyTrigger(KeyInput.KEY_PGUP));
inputManager.addMapping("downRM", new KeyTrigger(KeyInput.KEY_PGDN));
// createBox();
// createFire();
}
Aggregations