libgdx / box2dlights

Fork of box2dlights by Kalle Hamalainen
Apache License 2.0
256 stars 81 forks source link

v1.2 - v1.3 light color differences #38

Closed Aure77 closed 9 years ago

Aure77 commented 9 years ago

I am actually using box2dlights 1.2 with this settings :

// Initialize light ray handler
RayHandler.useDiffuseLight(true);
rayHandler = new RayHandler(world);
rayHandler.setAmbientLight(0.0f);

...
PointLight light = new PointLight(rayHandler, 32, Color.YELLOW, 30, 0, 0);
//light.setStaticLight(true);
light.setSoft(true);
light.attachToBody(body, 0, 0);

That render this : https://i.imgur.com/rugDUNt.jpg

I have tried to upgrade to 1.3 but I got a strange behavior with same code : https://i.imgur.com/po5rK3c.jpg color is dull and light feel more darker.

Why ?

EDIT: I Saw that : https://github.com/rinold/box2dlights/commit/e8c1010ee78c0e1c971e50cf5e57999565f00d3e#diff-bb6de2497b7e4551aee180796561d089R541 but I cannot modify diffuse blend function from RayHandler (from master). How to make light more flashy ?

rinold commented 9 years ago

Hi @Aure77,

In the 1.3 you can set the previous 1.2 blending model using following code:

rayHandler.diffuseBlendFunc.set(GL20.GL_DST_COLOR, GL20.GL_SRC_COLOR);
Aure77 commented 9 years ago

Thanks. But now, how to access to light list from rayhandler (now not public) ? Because I would like to remove light but I only now attached body. Previously I do that :+1:

for (Light light : rayHandler.lightList) {
  if(currentBody.equals(light.getBody())) {
    light.remove();
    break;
  }
}

There is a lot of changes but I don't find changelog.

rinold commented 9 years ago

If you do not use the Body/Fixture user data you can workaround it when linking light and body:

...
light.attachToBody(body);
body.setUserData(light);
... // and then:
((Light)currentBody.getUserData()).remove();

Regarding the rayHandler.lightList being private think that's not correct and is a side-effect issue introduced in 1.3 version, I'll check it and fix if needed.