Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directional Light has a top and bottom #61

Open
acegiak opened this issue May 26, 2015 · 5 comments
Open

Directional Light has a top and bottom #61

acegiak opened this issue May 26, 2015 · 5 comments
Labels

Comments

@acegiak
Copy link

acegiak commented May 26, 2015

When using DirectionalLight in a game with panning camera and wide box2d world DirectionalLight is not vertically infinite. It ends at +50y and -50y

Other lights outside this range continue to act as normal.

amygdalascreenshot1432611006922
amygdalascreenshot1432611298333

@rinold
Copy link
Contributor

rinold commented May 26, 2015

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?

@acegiak
Copy link
Author

acegiak commented May 27, 2015

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();

@rinold rinold added the bug label May 27, 2015
@rinold
Copy link
Contributor

rinold commented May 27, 2015

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?

@acegiak
Copy link
Author

acegiak commented May 28, 2015

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.

@mk-5
Copy link

mk-5 commented Oct 6, 2017

I have same issue.
I solved it by changing Directional Light direction from -90f to -91f - for me that's helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants