Search in sources :

Example 1 with PssmShadowRenderer

use of com.jme3.shadow.PssmShadowRenderer in project jmonkeyengine by jMonkeyEngine.

the class TestCinematic method createScene.

private void createScene() {
    model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    model.center();
    model.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(model);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Cyan);
    teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    teapot.setLocalTranslation(10, 0, 10);
    teapot.setMaterial(mat);
    teapot.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(teapot);
    Material matSoil = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    matSoil.setBoolean("UseMaterialColors", true);
    matSoil.setColor("Ambient", ColorRGBA.Gray);
    matSoil.setColor("Diffuse", ColorRGBA.Green);
    matSoil.setColor("Specular", ColorRGBA.Black);
    Geometry soil = new Geometry("soil", new Box(50, 1, 50));
    soil.setLocalTranslation(0, -6, 0);
    soil.setMaterial(matSoil);
    soil.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(soil);
    DirectionalLight light = new DirectionalLight();
    light.setDirection(new Vector3f(0, -1, -1).normalizeLocal());
    light.setColor(ColorRGBA.White.mult(1.5f));
    rootNode.addLight(light);
    fpp = new FilterPostProcessor(assetManager);
    fade = new FadeFilter();
    fpp.addFilter(fade);
    if (renderer.getCaps().contains(Caps.GLSL100)) {
        PssmShadowRenderer pssm = new PssmShadowRenderer(assetManager, 512, 1);
        pssm.setDirection(new Vector3f(0, -1, -1).normalizeLocal());
        pssm.setShadowIntensity(0.4f);
        viewPort.addProcessor(pssm);
        viewPort.addProcessor(fpp);
    }
}
Also used : Geometry(com.jme3.scene.Geometry) PssmShadowRenderer(com.jme3.shadow.PssmShadowRenderer) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) Box(com.jme3.scene.shape.Box) FilterPostProcessor(com.jme3.post.FilterPostProcessor) FadeFilter(com.jme3.post.filters.FadeFilter)

Example 2 with PssmShadowRenderer

use of com.jme3.shadow.PssmShadowRenderer in project jmonkeyengine by jMonkeyEngine.

the class TestPssmShadow method simpleInitApp.

@Override
public void simpleInitApp() {
    // put the camera in a bad position
    cam.setLocation(new Vector3f(65.25412f, 44.38738f, 9.087874f));
    cam.setRotation(new Quaternion(0.078139365f, 0.050241485f, -0.003942559f, 0.9956679f));
    flyCam.setMoveSpeed(100);
    loadScene();
    pssmRenderer = new PssmShadowRenderer(assetManager, 1024, 3);
    //pssmRenderer.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    pssmRenderer.setDirection(new Vector3f(-0.5973172f, -0.56583486f, 0.8846725f).normalizeLocal());
    pssmRenderer.setLambda(0.55f);
    pssmRenderer.setShadowIntensity(0.6f);
    pssmRenderer.setCompareMode(CompareMode.Software);
    pssmRenderer.setFilterMode(FilterMode.Dither);
    pssmRenderer.displayFrustum();
    viewPort.addProcessor(pssmRenderer);
    pssmFilter = new PssmShadowFilter(assetManager, 1024, 3);
    //pssmFilter.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    pssmRenderer.setDirection(new Vector3f(-0.5973172f, -0.56583486f, 0.8846725f).normalizeLocal());
    pssmFilter.setLambda(0.55f);
    pssmFilter.setShadowIntensity(0.6f);
    pssmFilter.setCompareMode(CompareMode.Software);
    pssmFilter.setFilterMode(FilterMode.Dither);
    pssmFilter.setEnabled(false);
    //        pssmFilter.setShadowZFadeLength(300);
    //        pssmFilter.setShadowZExtend(500);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    //  fpp.setNumSamples(4);
    fpp.addFilter(pssmFilter);
    viewPort.addProcessor(fpp);
    initInputs();
}
Also used : PssmShadowFilter(com.jme3.shadow.PssmShadowFilter) PssmShadowRenderer(com.jme3.shadow.PssmShadowRenderer) Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) FilterPostProcessor(com.jme3.post.FilterPostProcessor)

Example 3 with PssmShadowRenderer

use of com.jme3.shadow.PssmShadowRenderer in project jmonkeyengine by jMonkeyEngine.

the class TestBrickTower method simpleInitApp.

@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
    //   bulletAppState.setEnabled(false);
    stateManager.attach(bulletAppState);
    bullet = new Sphere(32, 32, 0.4f, true, false);
    bullet.setTextureMode(TextureMode.Projected);
    bulletCollisionShape = new SphereCollisionShape(0.4f);
    brick = new Box(brickWidth, brickHeight, brickDepth);
    brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
    //bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    initMaterial();
    initTower();
    initFloor();
    initCrossHairs();
    this.cam.setLocation(new Vector3f(0, 25f, 8f));
    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
    cam.setFrustumFar(80);
    inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(actionListener, "shoot");
    rootNode.setShadowMode(ShadowMode.Off);
    bsr = new PssmShadowRenderer(assetManager, 1024, 2);
    bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    bsr.setLambda(0.55f);
    bsr.setShadowIntensity(0.6f);
    bsr.setCompareMode(CompareMode.Hardware);
    bsr.setFilterMode(FilterMode.PCF4);
    viewPort.addProcessor(bsr);
}
Also used : Sphere(com.jme3.scene.shape.Sphere) SphereCollisionShape(com.jme3.bullet.collision.shapes.SphereCollisionShape) PssmShadowRenderer(com.jme3.shadow.PssmShadowRenderer) Vector2f(com.jme3.math.Vector2f) BulletAppState(com.jme3.bullet.BulletAppState) Vector3f(com.jme3.math.Vector3f) Box(com.jme3.scene.shape.Box) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger)

Example 4 with PssmShadowRenderer

use of com.jme3.shadow.PssmShadowRenderer in project jmonkeyengine by jMonkeyEngine.

the class TestHoveringTank method simpleInitApp.

@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
    stateManager.attach(bulletAppState);
    //        bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    bulletAppState.getPhysicsSpace().setAccuracy(1f / 30f);
    rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));
    PssmShadowRenderer pssmr = new PssmShadowRenderer(assetManager, 2048, 3);
    pssmr.setDirection(new Vector3f(-0.5f, -0.3f, -0.3f).normalizeLocal());
    pssmr.setLambda(0.55f);
    pssmr.setShadowIntensity(0.6f);
    pssmr.setCompareMode(CompareMode.Hardware);
    pssmr.setFilterMode(FilterMode.Bilinear);
    viewPort.addProcessor(pssmr);
    setupKeys();
    createTerrain();
    buildPlayer();
    DirectionalLight dl = new DirectionalLight();
    dl.setColor(new ColorRGBA(1.0f, 0.94f, 0.8f, 1f).multLocal(1.3f));
    dl.setDirection(new Vector3f(-0.5f, -0.3f, -0.3f).normalizeLocal());
    rootNode.addLight(dl);
    Vector3f lightDir2 = new Vector3f(0.70518064f, 0.5902297f, -0.39287305f);
    DirectionalLight dl2 = new DirectionalLight();
    dl2.setColor(new ColorRGBA(0.7f, 0.85f, 1.0f, 1f));
    dl2.setDirection(lightDir2);
    rootNode.addLight(dl2);
}
Also used : PssmShadowRenderer(com.jme3.shadow.PssmShadowRenderer) BulletAppState(com.jme3.bullet.BulletAppState) DirectionalLight(com.jme3.light.DirectionalLight)

Aggregations

PssmShadowRenderer (com.jme3.shadow.PssmShadowRenderer)4 Vector3f (com.jme3.math.Vector3f)3 BulletAppState (com.jme3.bullet.BulletAppState)2 DirectionalLight (com.jme3.light.DirectionalLight)2 FilterPostProcessor (com.jme3.post.FilterPostProcessor)2 Box (com.jme3.scene.shape.Box)2 SphereCollisionShape (com.jme3.bullet.collision.shapes.SphereCollisionShape)1 MouseButtonTrigger (com.jme3.input.controls.MouseButtonTrigger)1 Material (com.jme3.material.Material)1 Quaternion (com.jme3.math.Quaternion)1 Vector2f (com.jme3.math.Vector2f)1 FadeFilter (com.jme3.post.filters.FadeFilter)1 Geometry (com.jme3.scene.Geometry)1 Sphere (com.jme3.scene.shape.Sphere)1 PssmShadowFilter (com.jme3.shadow.PssmShadowFilter)1