Andrew
Andrew

Reputation: 1109

box2d - How do I render lights in a proper way?

Can you modify the darkness you get on screen when using a ray handler in libgdx with box2d world? Also when I put lights over sprites they look different because the light is on top of them. Can you render lights so that the color of the sprite is the same, even though it is lighted up by a source?

Upvotes: 1

Views: 649

Answers (1)

Jelle Blaauw
Jelle Blaauw

Reputation: 129

Yes. You can modify the darkness by setting ambient light. For instance:

rayHandler.setAmbientLight(0.5f);

makes everything 50% brighter.

Also, if you find that the lights over your sprites cause too much of a difference in colour, you might want to set the light's colour to white and set the alpha lower (just tweak around with it until you think it looks good).

Upvotes: 2

Related Questions