Java Code Examples for com.jme3.post.FilterPostProcessor#setNumSamples()

The following examples show how to use com.jme3.post.FilterPostProcessor#setNumSamples() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestFog.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    this.flyCam.setMoveSpeed(50);
    Node mainScene=new Node();
    cam.setLocation(new Vector3f(-34.74095f, 95.21318f, -287.4945f));
    cam.setRotation(new Quaternion(0.023536969f, 0.9361278f, -0.016098259f, -0.35050195f));

    // load sky
    mainScene.attachChild(SkyFactory.createSky(assetManager, 
            "Textures/Sky/Bright/BrightSky.dds", 
            SkyFactory.EnvMapType.CubeMap));
    createTerrain(mainScene);



    DirectionalLight sun = new DirectionalLight();
    Vector3f lightDir=new Vector3f(-0.37352666f, -0.50444174f, -0.7784704f);
    sun.setDirection(lightDir);
    sun.setColor(ColorRGBA.White.clone().multLocal(2));
    mainScene.addLight(sun);

    rootNode.attachChild(mainScene);

    fpp=new FilterPostProcessor(assetManager);
    //fpp.setNumSamples(4);
    int numSamples = getContext().getSettings().getSamples();
    if( numSamples > 0 ) {
        fpp.setNumSamples(numSamples); 
    }
    fog=new FogFilter();
    fog.setFogColor(new ColorRGBA(0.9f, 0.9f, 0.9f, 1.0f));
    fog.setFogDistance(155);
    fog.setFogDensity(1.0f);
    fpp.addFilter(fog);
    viewPort.addProcessor(fpp);
    initInputs();
}
 
Example 2
Source File: TestCartoonEdge.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupFilters(){
    if (renderer.getCaps().contains(Caps.GLSL100)){
        fpp=new FilterPostProcessor(assetManager);
        //fpp.setNumSamples(4);
        int numSamples = getContext().getSettings().getSamples();
        if( numSamples > 0 ) {
            fpp.setNumSamples(numSamples); 
        }
        CartoonEdgeFilter toon=new CartoonEdgeFilter();
        toon.setEdgeColor(ColorRGBA.Yellow);
        fpp.addFilter(toon);
        viewPort.addProcessor(fpp);
    }
}
 
Example 3
Source File: TestBloomAlphaThreshold.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp()
{
	// put the camera in a bad position
	cam.setLocation(new Vector3f(-2.336393f, 11.91392f, -10));
	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));
	mat.setColor("GlowColor", ColorRGBA.Green);

	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);

               Vector3f boxMin1 = new Vector3f(-800f, -23f, -150f);
               Vector3f boxMax1 = new Vector3f(800f, 3f, 1250f);
               Box boxMesh1 = new Box(boxMin1, boxMax1);
	Geometry soil = new Geometry("soil", boxMesh1);
	soil.setMaterial(matSoil);
	soil.setShadowMode(ShadowMode.CastAndReceive);
	rootNode.attachChild(soil);

	Material matBox = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
	matBox.setTexture("ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png"));
	matBox.setFloat("AlphaDiscardThreshold", 0.5f);
   
               Vector3f boxMin2 = new Vector3f(-5.5f, 8f, -4f);
               Vector3f boxMax2 = new Vector3f(-1.5f, 12f, 0f);
               Box boxMesh2 = new Box(boxMin2, boxMax2);
	Geometry box = new Geometry("box", boxMesh2);
	box.setMaterial(matBox);
               box.setQueueBucket(RenderQueue.Bucket.Translucent);
	// box.setShadowMode(ShadowMode.CastAndReceive);
	rootNode.attachChild(box);

	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",
                       EnvMapType.CubeMap);
	sky.setCullHint(Spatial.CullHint.Never);
	rootNode.attachChild(sky);

	fpp = new FilterPostProcessor(assetManager);
	int numSamples = getContext().getSettings().getSamples();
	if (numSamples > 0)
	{
		fpp.setNumSamples(numSamples);
	}

	BloomFilter bloom = new BloomFilter(GlowMode.Objects);
	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();

}
 
Example 4
Source File: TestLightScattering.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
    public void simpleInitApp() {
        // put the camera in a bad position
        cam.setLocation(new Vector3f(55.35316f, -0.27061665f, 27.092093f));
        cam.setRotation(new Quaternion(0.010414706f, 0.9874893f, 0.13880467f, -0.07409228f));
//        cam.setDirection(new Vector3f(0,-0.5f,1.0f));
//        cam.setLocation(new Vector3f(0, 300, -500));
        //cam.setFrustumFar(1000);
        flyCam.setMoveSpeed(10);
        Material mat = assetManager.loadMaterial("Textures/Terrain/Rocky/Rocky.j3m");
        Spatial scene = assetManager.loadModel("Models/Terrain/Terrain.mesh.xml");
        TangentBinormalGenerator.generate(((Geometry)((Node)scene).getChild(0)).getMesh());
        scene.setMaterial(mat);
        scene.setShadowMode(ShadowMode.CastAndReceive);
        scene.setLocalScale(400);
        scene.setLocalTranslation(0, -10, -120);

        rootNode.attachChild(scene);

        // load sky
        rootNode.attachChild(SkyFactory.createSky(assetManager,
                "Textures/Sky/Bright/FullskiesBlueClear03.dds", 
                SkyFactory.EnvMapType.CubeMap));

        DirectionalLight sun = new DirectionalLight();
        Vector3f lightDir = new Vector3f(-0.12f, -0.3729129f, 0.74847335f);
        sun.setDirection(lightDir);
        sun.setColor(ColorRGBA.White.clone().multLocal(2));
        scene.addLight(sun);


        FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
        int numSamples = getContext().getSettings().getSamples();
        if (numSamples > 0) {
            fpp.setNumSamples(numSamples);
        }
        Vector3f lightPos = lightDir.multLocal(-3000);
        LightScatteringFilter filter = new LightScatteringFilter(lightPos);
        LightScatteringUI ui = new LightScatteringUI(inputManager, filter);
        fpp.addFilter(filter);
        viewPort.addProcessor(fpp);
    }
 
Example 5
Source File: TestSSAO2.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@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);
//        Sphere sph = new Sphere(16, 16, 4);
//        Geometry teapot = new Geometry("teapot", sph);



        // show normals as material
        //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);
    }
 
Example 6
Source File: TestPosterization.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@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));

    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", SkyFactory.EnvMapType.CubeMap);
    sky.setCullHint(Spatial.CullHint.Never);
    rootNode.attachChild(sky);

    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    int numSamples = getContext().getSettings().getSamples();
    if (numSamples > 0) {
        fpp.setNumSamples(numSamples);
    }
    pf = new PosterizationFilter();
    fpp.addFilter(pf);

    viewPort.addProcessor(fpp);
    initInputs();

}
 
Example 7
Source File: TestBloom.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@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", 
            EnvMapType.CubeMap);
    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();

}
 
Example 8
Source File: TestCrossHatch.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@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",
            EnvMapType.CubeMap);
    sky.setCullHint(Spatial.CullHint.Never);
    rootNode.attachChild(sky);

    fpp=new FilterPostProcessor(assetManager);
    
    int numSamples = getContext().getSettings().getSamples();
    if( numSamples > 0 ) {
        fpp.setNumSamples(numSamples); 
    }
    
    CrossHatchFilter chf=new CrossHatchFilter();
    
   

    viewPort.addProcessor(fpp);
    fpp.addFilter(chf);
    initInputs();

}