libgdx / box2dlights

Fork of box2dlights by Kalle Hamalainen
Apache License 2.0
257 stars 82 forks source link

PointLight bleeding into blocked areas #76

Closed adam-law closed 9 years ago

adam-law commented 9 years ago

I procedurally generate light blocking areas using static Box2D bodies, and I've come across an issue where point lights sometimes penetrate these bodies, depending on where the light source is.

Using the debug renderer The image below shows what I mean, the some of the green boxes to the left side of the character has light bleeding into them: bleeding

I have worse pictures, where the light illuminates entire boxes of blocked areas. It seems to happen more with light shed toward the left, and seldom on areas to the right. Using cone lights, box2dLights works perfectly, no bleeding at all.

I've played around with softness, and the length of softness, but the issue still occurs.

Edit 1: An idea hit me, so I increased the ray count, and it helped dramatically. I was using modest values of 5 to 20. I found that it had to be a value from around 50 to 100+, and I'm wondering if it really has to be like this, since it seems to be expensive if point lights have to have at least this much rays, in order to collide correctly with box2d bodies.