Yeah, I know there's already a light library for love2d, but I created one by my own anyway.
It's VERY SLOW. VEEEEEERY SLOW. It can't be used in normal games, it's just a test I made.
If you have any suggestions on how to make the code better, or just have an opinion, reply!
Light system test
Light system test
- Attachments
-
- lights.love
- (841 Bytes) Downloaded 169 times
Re: Light system test
Hello. It's ok, but the code needs a lot of work.
For starters you need to use locals for stuff like:
Generally I don't think it's a good idea to cast rays in every direction,
a cleverer approach would be to cast the rays to specific vertices in the scene.
As an optimization, you could ignore vertices that are too far away and edges that are "facing away".
It's possible to do a lot of fancy stuff using math alone, but I think a hardware accelerated solution
would be a better move at some point in the future.
For starters you need to use locals for stuff like:
Code: Select all
if light.x+(math.cos(ray.angle)*ray.len) >= box.x and light.x+(math.cos(ray.angle)*ray.len) <= box.x+box.w and
light.y+(math.sin(ray.angle)*ray.len) >= box.y and light.y+(math.sin(ray.angle)*ray.len) <= box.y+box.h then
keepdoing = false
end
a cleverer approach would be to cast the rays to specific vertices in the scene.
As an optimization, you could ignore vertices that are too far away and edges that are "facing away".
It's possible to do a lot of fancy stuff using math alone, but I think a hardware accelerated solution
would be a better move at some point in the future.
Re: Light system test
i got 30 fps solid with it... thats decent.
Who is online
Users browsing this forum: No registered users and 2 guests