Search in sources :

Example 51 with RenderManager

use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.

the class BloomFilter method initFilter.

@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
    this.renderManager = renderManager;
    this.viewPort = vp;
    this.assetManager = manager;
    this.initalWidth = w;
    this.initalHeight = h;
    screenWidth = (int) Math.max(1, (w / downSamplingFactor));
    screenHeight = (int) Math.max(1, (h / downSamplingFactor));
    //    System.out.println(screenWidth + " " + screenHeight);
    if (glowMode != GlowMode.Scene) {
        preGlowPass = new Pass();
        preGlowPass.init(renderManager.getRenderer(), screenWidth, screenHeight, Format.RGBA8, Format.Depth);
    }
    postRenderPasses = new ArrayList<Pass>();
    //configuring extractPass
    extractMat = new Material(manager, "Common/MatDefs/Post/BloomExtract.j3md");
    extractPass = new Pass() {

        @Override
        public boolean requiresSceneAsTexture() {
            return true;
        }

        @Override
        public void beforeRender() {
            extractMat.setFloat("ExposurePow", exposurePower);
            extractMat.setFloat("ExposureCutoff", exposureCutOff);
            if (glowMode != GlowMode.Scene) {
                extractMat.setTexture("GlowMap", preGlowPass.getRenderedTexture());
            }
            extractMat.setBoolean("Extract", glowMode != GlowMode.Objects);
        }
    };
    extractPass.init(renderManager.getRenderer(), screenWidth, screenHeight, Format.RGBA8, Format.Depth, 1, extractMat);
    postRenderPasses.add(extractPass);
    //configuring horizontal blur pass
    hBlurMat = new Material(manager, "Common/MatDefs/Blur/HGaussianBlur.j3md");
    horizontalBlur = new Pass() {

        @Override
        public void beforeRender() {
            hBlurMat.setTexture("Texture", extractPass.getRenderedTexture());
            hBlurMat.setFloat("Size", screenWidth);
            hBlurMat.setFloat("Scale", blurScale);
        }
    };
    horizontalBlur.init(renderManager.getRenderer(), screenWidth, screenHeight, Format.RGBA8, Format.Depth, 1, hBlurMat);
    postRenderPasses.add(horizontalBlur);
    //configuring vertical blur pass
    vBlurMat = new Material(manager, "Common/MatDefs/Blur/VGaussianBlur.j3md");
    verticalalBlur = new Pass() {

        @Override
        public void beforeRender() {
            vBlurMat.setTexture("Texture", horizontalBlur.getRenderedTexture());
            vBlurMat.setFloat("Size", screenHeight);
            vBlurMat.setFloat("Scale", blurScale);
        }
    };
    verticalalBlur.init(renderManager.getRenderer(), screenWidth, screenHeight, Format.RGBA8, Format.Depth, 1, vBlurMat);
    postRenderPasses.add(verticalalBlur);
    //final material
    material = new Material(manager, "Common/MatDefs/Post/BloomFinal.j3md");
    material.setTexture("BloomTex", verticalalBlur.getRenderedTexture());
}
Also used : Material(com.jme3.material.Material)

Example 52 with RenderManager

use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.

the class CartoonEdgeFilter method initFilter.

@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
    this.renderManager = renderManager;
    this.viewPort = vp;
    normalPass = new Pass();
    normalPass.init(renderManager.getRenderer(), w, h, Format.RGBA8, Format.Depth);
    material = new Material(manager, "Common/MatDefs/Post/CartoonEdge.j3md");
    material.setFloat("EdgeWidth", edgeWidth);
    material.setFloat("EdgeIntensity", edgeIntensity);
    material.setFloat("NormalThreshold", normalThreshold);
    material.setFloat("DepthThreshold", depthThreshold);
    material.setFloat("NormalSensitivity", normalSensitivity);
    material.setFloat("DepthSensitivity", depthSensitivity);
    material.setColor("EdgeColor", edgeColor);
}
Also used : Pass(com.jme3.post.Filter.Pass) Material(com.jme3.material.Material)

Example 53 with RenderManager

use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.

the class ColorOverlayFilter method initFilter.

@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
    material = new Material(manager, "Common/MatDefs/Post/Overlay.j3md");
    material.setColor("Color", color);
}
Also used : Material(com.jme3.material.Material)

Example 54 with RenderManager

use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.

the class CrossHatchFilter method initFilter.

@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
    material = new Material(manager, "Common/MatDefs/Post/CrossHatch.j3md");
    material.setColor("LineColor", lineColor);
    material.setColor("PaperColor", paperColor);
    material.setFloat("ColorInfluenceLine", colorInfluenceLine);
    material.setFloat("ColorInfluencePaper", colorInfluencePaper);
    material.setFloat("FillValue", fillValue);
    material.setFloat("Luminance1", luminance1);
    material.setFloat("Luminance2", luminance2);
    material.setFloat("Luminance3", luminance3);
    material.setFloat("Luminance4", luminance4);
    material.setFloat("Luminance5", luminance5);
    material.setFloat("LineThickness", lineThickness);
    material.setFloat("LineDistance", lineDistance);
}
Also used : Material(com.jme3.material.Material)

Example 55 with RenderManager

use of com.jme3.renderer.RenderManager in project jmonkeyengine by jMonkeyEngine.

the class GammaCorrectionFilter method initFilter.

@Override
protected void initFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
    material = new Material(manager, "Common/MatDefs/Post/GammaCorrection.j3md");
    material.setFloat("InvGamma", 1.0f / gamma);
}
Also used : Material(com.jme3.material.Material)

Aggregations

Material (com.jme3.material.Material)25 Camera (com.jme3.renderer.Camera)15 Renderer (com.jme3.renderer.Renderer)11 Vector3f (com.jme3.math.Vector3f)8 Texture2D (com.jme3.texture.Texture2D)5 DirectionalLight (com.jme3.light.DirectionalLight)4 Geometry (com.jme3.scene.Geometry)4 Picture (com.jme3.ui.Picture)4 TempVars (com.jme3.util.TempVars)4 Light (com.jme3.light.Light)3 PointLight (com.jme3.light.PointLight)3 SpotLight (com.jme3.light.SpotLight)3 Pass (com.jme3.post.Filter.Pass)3 RenderManager (com.jme3.renderer.RenderManager)3 Spatial (com.jme3.scene.Spatial)3 Shader (com.jme3.shader.Shader)3 FrameBuffer (com.jme3.texture.FrameBuffer)3 Texture (com.jme3.texture.Texture)3 Test (org.junit.Test)3 Technique (com.jme3.material.Technique)2