use of com.jme3.shadow.DirectionalLightShadowRenderer in project jmonkeyengine by jMonkeyEngine.
the class DirectionalLightShadowFilter method read.
@Override
public void read(JmeImporter im) throws IOException {
super.read(im);
InputCapsule ic = im.getCapsule(this);
shadowRenderer = (DirectionalLightShadowRenderer) ic.readSavable("shadowRenderer", null);
}
use of com.jme3.shadow.DirectionalLightShadowRenderer in project jmonkeyengine by jMonkeyEngine.
the class TestColorApp method simpleInitApp.
@Override
public void simpleInitApp() {
// Lights
DirectionalLight sun = new DirectionalLight();
Vector3f sunPosition = new Vector3f(1, -1, 1);
sun.setDirection(sunPosition);
sun.setColor(new ColorRGBA(1f, 1f, 1f, 1f));
rootNode.addLight(sun);
//DirectionalLightShadowFilter sun_renderer = new DirectionalLightShadowFilter(assetManager, 2048, 4);
DirectionalLightShadowRenderer sun_renderer = new DirectionalLightShadowRenderer(assetManager, 2048, 1);
sun_renderer.setLight(sun);
viewPort.addProcessor(sun_renderer);
// FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
// fpp.addFilter(sun_renderer);
// viewPort.addProcessor(fpp);
rootNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
// Camera
viewPort.setBackgroundColor(new ColorRGBA(.6f, .6f, .6f, 1f));
ChaseCamera chaseCam = new ChaseCamera(cam, inputManager);
// Objects
// Ground Object
final Geometry groundBoxWhite = new Geometry("Box", new Box(7.5f, 7.5f, .25f));
float[] f = { -FastMath.PI / 2, 3 * FastMath.PI / 2, 0f };
groundBoxWhite.setLocalRotation(new Quaternion(f));
groundBoxWhite.move(7.5f, -.75f, 7.5f);
final Material groundMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
groundMaterial.setColor("Diffuse", new ColorRGBA(.9f, .9f, .9f, .9f));
groundBoxWhite.setMaterial(groundMaterial);
groundBoxWhite.addControl(chaseCam);
rootNode.attachChild(groundBoxWhite);
// Planter
Geometry planterBox = new Geometry("Box", new Box(.5f, .5f, .5f));
final Material planterMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
planterMaterial.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
planterBox.setMaterial(groundMaterial);
planterBox.setLocalTranslation(10, 0, 9);
rootNode.attachChild(planterBox);
// Action!
inputManager.addMapping("on", new KeyTrigger(KeyInput.KEY_Z));
inputManager.addMapping("off", new KeyTrigger(KeyInput.KEY_X));
inputManager.addListener(new AnalogListener() {
@Override
public void onAnalog(String s, float v, float v1) {
if (s.equals("on")) {
groundBoxWhite.setMaterial(planterMaterial);
}
if (s.equals("off")) {
groundBoxWhite.setMaterial(groundMaterial);
}
}
}, "on", "off");
inputEnabled = true;
}
use of com.jme3.shadow.DirectionalLightShadowRenderer in project jmonkeyengine by jMonkeyEngine.
the class TestDirectionalLightShadow 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));
cam.setLocation(new Vector3f(3.3720117f, 42.838284f, -83.43792f));
cam.setRotation(new Quaternion(0.13833192f, -0.08969371f, 0.012581267f, 0.9862358f));
flyCam.setMoveSpeed(100);
loadScene();
dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 3);
dlsr.setLight(l);
dlsr.setLambda(0.55f);
dlsr.setShadowIntensity(0.8f);
dlsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
dlsr.displayDebug();
viewPort.addProcessor(dlsr);
dlsf = new DirectionalLightShadowFilter(assetManager, SHADOWMAP_SIZE, 3);
dlsf.setLight(l);
dlsf.setLambda(0.55f);
dlsf.setShadowIntensity(0.8f);
dlsf.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
dlsf.setEnabled(false);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
fpp.addFilter(dlsf);
viewPort.addProcessor(fpp);
initInputs();
}
use of com.jme3.shadow.DirectionalLightShadowRenderer in project jmonkeyengine by jMonkeyEngine.
the class TestShadowsPerf method simpleInitApp.
@Override
public void simpleInitApp() {
Logger.getLogger("com.jme3").setLevel(Level.SEVERE);
flyCam.setMoveSpeed(50);
flyCam.setEnabled(false);
viewPort.setBackgroundColor(ColorRGBA.DarkGray);
cam.setLocation(new Vector3f(-53.952988f, 27.15874f, -32.875023f));
cam.setRotation(new Quaternion(0.1564309f, 0.6910534f, -0.15713608f, 0.6879555f));
// cam.setLocation(new Vector3f(53.64627f, 130.56f, -11.247704f));
// cam.setRotation(new Quaternion(-6.5737107E-4f, 0.76819664f, -0.64021313f, -7.886125E-4f));
////
cam.setFrustumFar(500);
mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
Box b = new Box(800, 1, 700);
b.scaleTextureCoordinates(new Vector2f(50, 50));
Geometry ground = new Geometry("ground", b);
ground.setMaterial(mat);
rootNode.attachChild(ground);
ground.setShadowMode(ShadowMode.Receive);
Sphere sphMesh = new Sphere(32, 32, 1);
sphMesh.setTextureMode(Sphere.TextureMode.Projected);
sphMesh.updateGeometry(32, 32, 1, false, false);
TangentBinormalGenerator.generate(sphMesh);
sphere = new Geometry("Rock Ball", sphMesh);
sphere.setLocalTranslation(0, 5, 0);
sphere.setMaterial(mat);
sphere.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(sphere);
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(0, -1, 0).normalizeLocal());
dl.setColor(ColorRGBA.White);
rootNode.addLight(dl);
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(0.7f));
rootNode.addLight(al);
//rootNode.setShadowMode(ShadowMode.CastAndReceive);
createballs();
final DirectionalLightShadowRenderer pssmRenderer = new DirectionalLightShadowRenderer(assetManager, 1024, 4);
viewPort.addProcessor(pssmRenderer);
//
// final PssmShadowFilter pssmRenderer = new PssmShadowFilter(assetManager, 1024, 4);
// FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
// fpp.addFilter(pssmRenderer);
// viewPort.addProcessor(fpp);
pssmRenderer.setLight(dl);
pssmRenderer.setLambda(0.55f);
pssmRenderer.setShadowIntensity(0.55f);
pssmRenderer.setShadowCompareMode(com.jme3.shadow.CompareMode.Software);
pssmRenderer.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
//pssmRenderer.displayDebug();
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("display") && isPressed) {
//pssmRenderer.debugFrustrums();
System.out.println("tetetetet");
}
if (name.equals("add") && isPressed) {
createballs();
}
}
}, "display", "add");
inputManager.addMapping("display", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("add", new KeyTrigger(KeyInput.KEY_RETURN));
}
use of com.jme3.shadow.DirectionalLightShadowRenderer in project jmonkeyengine by jMonkeyEngine.
the class TestPbrEnv method simpleInitApp.
@Override
public void simpleInitApp() {
assetManager.registerLoader(KTXLoader.class, "ktx");
// put the camera in a bad position
cam.setLocation(new Vector3f(-52.433647f, 68.69636f, -118.60924f));
cam.setRotation(new Quaternion(0.10294232f, 0.25269797f, -0.027049713f, 0.96167296f));
flyCam.setMoveSpeed(100);
loadScene();
dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 4);
dlsr.setLight(l);
//dlsr.setLambda(0.55f);
dlsr.setShadowIntensity(0.5f);
dlsr.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
//dlsr.displayDebug();
// viewPort.addProcessor(dlsr);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
fpp.addFilter(new ToneMapFilter(Vector3f.UNIT_XYZ.mult(6.0f)));
SSAOFilter ssao = new SSAOFilter();
ssao.setIntensity(5);
fpp.addFilter(ssao);
BloomFilter bloomFilter = new BloomFilter();
fpp.addFilter(bloomFilter);
fpp.addFilter(new FXAAFilter());
//viewPort.addProcessor(fpp);
initInputs();
// envManager = new EnvironmentManager();
// getStateManager().attach(envManager);
//
envCam = new EnvironmentCamera();
getStateManager().attach(envCam);
debugState = new LightsDebugState();
debugState.setProbeScale(5);
getStateManager().attach(debugState);
camGeom = new Geometry("camGeom", new Sphere(16, 16, 2));
// Material m = new Material(assetManager, "Common/MatDefs/Misc/UnshadedNodes.j3md");
// m.setColor("Color", ColorRGBA.Green);
Material m = assetManager.loadMaterial("jme3test/light/pbr/pbrMat3.j3m");
camGeom.setMaterial(m);
camGeom.setLocalTranslation(0, 20, 0);
camGeom.setLocalScale(5);
rootNode.attachChild(camGeom);
// envManager.setScene(rootNode);
// MaterialDebugAppState debug = new MaterialDebugAppState();
// debug.registerBinding("MatDefs/PBRLighting.frag", rootNode);
// getStateManager().attach(debug);
flyCam.setDragToRotate(true);
setPauseOnLostFocus(false);
// cam.lookAt(camGeom.getWorldTranslation(), Vector3f.UNIT_Y);
}
Aggregations