public void setupHdr(){ if (renderer.getCaps().contains(Caps.GLSL100)){ toneMapFilter = new ToneMapFilter(); toneMapFilter.setWhitePoint(new Vector3f(3f, 3f, 3f)); FilterPostProcessor fpp = new FilterPostProcessor(assetManager); fpp.addFilter(toneMapFilter); viewPort.addProcessor(fpp); // setPauseOnLostFocus(false); } }
@Override public void simpleInitApp() { System.out.println("== Tone Mapping Sample =="); System.out.println(" SPACE:\tToggle tone-mapping OFF or ON"); System.out.println(" Y:\tIncrease white-point"); System.out.println(" H:\tDecrease white-point"); fpp = new FilterPostProcessor(assetManager); toneMapFilter = new ToneMapFilter(); fpp.addFilter(toneMapFilter); viewPort.addProcessor(fpp); rootNode.attachChild(createHDRBox()); cam.setLocation(new Vector3f(0f,0f,3f)); initInputs(); }
public void onAnalog(String name, float isPressed, float tpf) { if (name.equals("WhitePointUp")) { whitePointLog += tpf * 1.0; if (whitePointLog > 4f) { whitePointLog = 4f; } float wp = FastMath.exp(whitePointLog); toneMapFilter.setWhitePoint(new Vector3f(wp, wp, wp)); System.out.println("White point: " + wp); } if (name.equals("WhitePointDown")) { whitePointLog -= tpf * 1.0; if (whitePointLog < -4f) { whitePointLog = -4f; } float wp = FastMath.exp(whitePointLog); toneMapFilter.setWhitePoint(new Vector3f(wp, wp, wp)); System.out.println("White point: " + wp); } } };
public void setupLighting(){ boolean hdr = false; if (toneMapFilter != null){ hdr = toneMapFilter.isEnabled(); } DirectionalLight dl = new DirectionalLight(); if (dlsr != null) { dlsr.setLight(dl); } dl.setDirection(lightDir); if (hdr){ dl.setColor(new ColorRGBA(3, 3, 3, 1)); }else{ dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1)); } rootNode.addLight(dl); dl = new DirectionalLight(); dl.setDirection(new Vector3f(1, 0, -1).normalizeLocal()); if (hdr){ dl.setColor(new ColorRGBA(1, 1, 1, 1)); }else{ dl.setColor(new ColorRGBA(.4f, .4f, .4f, 1)); } rootNode.addLight(dl); }
fpp.addFilter(new ToneMapFilter(Vector3f.UNIT_XYZ.mult(4.0f)));