JME-Graphics
implementation 'com.jayfella:jme-graphics:1.1.1'
The first of many libraries I’ll be uploading to jcenter. To use it, just add this dependency to your gradle project.
A global graphics object for jmonkey to allow modifying the various graphics configurations at any time during your game.
- Enable/disable post-processing effects easily.
- Manipulate camera view-frustum and field-of view.
- Set anistropic filtering level with a single line of code.
- Change resolution, frame-rate, vsync, etc… at any time in your game.
- Get the camera depth texture.
public class Main extends SimpleApplication {
public static void main(String... args) {
Main main = new Main();
main.start();
}
@Override
public void simpleInitApp() {
Graphics.initialize(this);
// Enable Anistripic Filtering
Graphics.getInstance().setAnistropicFilteringLevel(PowerLevel.SIXTEEN);
// change some camera settings
Graphics.getInstance().getCameraSettings().setFieldOfView(70);
Graphics.getInstance().getCameraSettings().setFrustumFar(1000);
// enable some built-in post-processing filters
Graphics.getInstance().getPostProcessor().setAmbientOcclusionEnabled(true);
Graphics.getInstance().getPostProcessor().setFxaaEnabled(true);
// enable an effect you made yourself
Graphics.getInstance().getPostProcessor().setFilterEnabled(MyFilter.class, true);
// get a filter
BloomFilter bloomFilter = Graphics.getInstance().getPostProcessor().getBloomFilter();
MyFilter myFilter = Graphics.getInstance().getPostProcessor().getFilter(MyFilter.class);
// modify any context settings
// since we enable FXAA we also need to set the strength.
Graphics.getInstance().getContextSettings().setNumSamples(PowerLevel.EIGHT);
Graphics.getInstance().getContextSettings().setResolution(1280, 720);
Graphics.getInstance().getContextSettings().setFrameRate(120);
// any time we change getContextSettings settings we must apply them.
// we "apply" manually so we can chain settings before applying them.
Graphics.getInstance().getContextSettings().apply();
// Get the camera depth texture and use it in a material
Texture2D depthTexture = Graphics.getInstance().getCameraSettings().getDepthTexture();
myMaterial.setTexture("DepthTexture", depthTexture);
}
}
Source code is available as always on github.