Hello, I’m trying to create a simple voxel game. And when I started creating shadows I saw that they were awful:
How can I fix it?
Also, cubes are created out of quads and then combined to mesh with GeometryBatchFactory.makeBatches
here is the code:
private void setUpShadowCasting() {
final int SHADOWMAP_SIZE = 512;
DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 1);
dlsr.setLight(sun);
viewPort.addProcessor(dlsr);
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(assetManager, SHADOWMAP_SIZE, 1);
dlsf.setLight(sun);
dlsf.setEnabled(true);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
fpp.addFilter(dlsf);
viewPort.addProcessor(fpp);
}
private void createSun() {
sun = new DirectionalLight();
sun.setColor(ColorRGBA.White);
sun.setDirection(new Vector3f(-.5f, -.5f, -.5f).normalizeLocal());
rootNode.addLight(sun);
}
Note: changing SHADOWMAP_SIZE
or nbSplits
doesn’t fix that situation.