Search in sources :

Example 1 with ComposeFilter

use of com.jme3.post.filters.ComposeFilter in project jmonkeyengine by jMonkeyEngine.

the class TestPostFiltersCompositing method simpleInitApp.

public void simpleInitApp() {
    this.flyCam.setMoveSpeed(10);
    cam.setLocation(new Vector3f(0.028406568f, 2.015769f, 7.386517f));
    cam.setRotation(new Quaternion(-1.0729783E-5f, 0.9999721f, -0.0073241726f, -0.0014647911f));
    makeScene();
    //Creating the main view port post processor
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(new ColorOverlayFilter(ColorRGBA.Blue));
    viewPort.addProcessor(fpp);
    //creating a frame buffer for the mainviewport
    FrameBuffer mainVPFrameBuffer = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1);
    Texture2D mainVPTexture = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8);
    mainVPFrameBuffer.addColorTexture(mainVPTexture);
    mainVPFrameBuffer.setDepthBuffer(Image.Format.Depth);
    viewPort.setOutputFrameBuffer(mainVPFrameBuffer);
    //creating the post processor for the gui viewport
    final FilterPostProcessor guifpp = new FilterPostProcessor(assetManager);
    guifpp.setFrameBufferFormat(Image.Format.RGBA8);
    guifpp.addFilter(new ColorOverlayFilter(ColorRGBA.Red));
    //this will compose the main viewport texture with the guiviewport back buffer.
    //Note that you can switch the order of the filters so that guiviewport filters are applied or not to the main viewport texture
    guifpp.addFilter(new ComposeFilter(mainVPTexture));
    guiViewPort.addProcessor(guifpp);
    //compositing is done by mixing texture depending on the alpha channel, 
    //it's important that the guiviewport clear color alpha value is set to 0
    guiViewPort.setBackgroundColor(ColorRGBA.BlackNoAlpha);
    guiViewPort.setClearColor(true);
}
Also used : Texture2D(com.jme3.texture.Texture2D) ColorOverlayFilter(com.jme3.post.filters.ColorOverlayFilter) ComposeFilter(com.jme3.post.filters.ComposeFilter) Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) FilterPostProcessor(com.jme3.post.FilterPostProcessor) FrameBuffer(com.jme3.texture.FrameBuffer)

Aggregations

Quaternion (com.jme3.math.Quaternion)1 Vector3f (com.jme3.math.Vector3f)1 FilterPostProcessor (com.jme3.post.FilterPostProcessor)1 ColorOverlayFilter (com.jme3.post.filters.ColorOverlayFilter)1 ComposeFilter (com.jme3.post.filters.ComposeFilter)1 FrameBuffer (com.jme3.texture.FrameBuffer)1 Texture2D (com.jme3.texture.Texture2D)1