libgdx / box2dlights

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

Added smooth lights #99

Closed piotr-j closed 7 years ago

piotr-j commented 7 years ago

Smooth lights are a drop in replacement for current lights. They cast rays more intelligently allowing to use less rays then comparable default light. See https://www.youtube.com/watch?v=24XHJPjpxy4 for example.

Code review would be great!

rinold commented 7 years ago

Video looks really great. But SO big... will need time.

One point - "smooth" doesn't give me much understanding :) Could you please provide some complete (brief, please, where possible) description of what and how it's different (without too much technical details - think will find that details in review). Just to understand the idea under it.

piotr-j commented 7 years ago

Smooth refers to how the light doesnt "jump" when objects move within its bounds. Eliminating this effect was the main goal of this project. Besides lights looking better, potential for better performance is also there in addition to some features not present in the current lights.

One of them is lights "sleeping", not updating when only static objects are present within the bounds, resulting in extra performance.

Jumping effect is easier to see when the video is played at .25 speed.

piotr-j commented 7 years ago

A lot of typos and todos and other stuff i see. Ill sort it all out tomorrow! Too bad i dont quite remember why certain values are the way they are. This code was rotting in the clouds for way too long!

rinold commented 7 years ago

Hmm... Dynamic rays, I've been thinking about it previously, but honestly haven't came to satisfying solution (performance). I still haven't checked all of this, but looks like you are processing the fixtures, which in case brings some performance degradation. Of course it is very-very "it depends". I feel that in quite a complex box2d environments, your solution might be much slower than used currently. While in others being quite faster.

Don't think I don't want this being merged, but we need to take care about it. If this should or not to replace the current lights - should be a weighted decision.

piotr-j commented 7 years ago

Its not designed to be a replacement, or even a default, but an alternative. As you said, the performance depends on a lot more variables then in the current implementation.

uaimedna commented 7 years ago

I would just like to say that "smooth" lights are exactly the thing that was missing from this project. The "jump" effect around the edges has prevented me from using this library multiple times in the past. The video looks great and I can't wait to get my hands on the library when this is merged. Great work!