Directional Light has a top and bottom
acegiak opened this issue · 5 comments
As I know the Directional light is limited by screen size dependent values which are set or updated when calling the:
rayHandler.setCombinedMatrix(...);
And there are no other limitations for this light. Could you please share some code regarding the usage of box2dlights and the DirectionalLight?
Yeah, I had a look through the DirectionalLight class before posting here and saw the way it should be getting the dimensions from the camera but that doesn't appear to be what's happening.
The key box2dlights and DirectionalLight code sections are here:
private void initiateLighting() {
if (Amygdala.lighting) {
rayHandler = new RayHandler(world);
rayHandler.setCombinedMatrix(camera);
rayHandler.setBlur(true);
rayHandler.setBlurNum(1);
rayHandler.setAmbientLight(DEFAULT_LIGHT_LEVEL);
sun = new DirectionalLight(rayHandler, Gdx.graphics.getWidth()/2, new Color(1f,1f,1f,SUN_INTENSITY), -90f);
sun.setActive(true);
sun.setStaticLight(false);
sun.setContactFilter(Entity.CATEGORY_LIGHT, (short) 0, Entity.MASK_LIGHT);
}
}
And here in our screen's render method:
if(rayHandler == null){
initiateLighting();
}
rayHandler.setCombinedMatrix(camera);
rayHandler.updateAndRender();
Oh... I've got it. The issue now is if we will move more correctly with camera position, the shadows from offscreen objects will blink if we move up-down. Need to think regarding something like fixed pseudo-position for DirectionalLight...
BTW, is your world limited by Y axis?
our player can theoretically move infinitely on the Y axis but the platforms are not so we could, for instance, after level generation, supply a max and min Y value to the rayhandler or directionallight outside of which there would not be anything to cast shadows or have shadows cast on it.
One of the things I was trying to work out if I could do myself was pass a rectangle with the level bounds to the directionallight but I don't have a deep enough understanding of the raytracing for that.
I have same issue.
I solved it by changing Directional Light direction from -90f to -91f - for me that's helped.