I know there are lots of shadow libraries out there but I wanted to make my own, here it is, light.
The code's on github.
This library allows you to add shadows to your game, it currently supports translation given that you provide a big enough canvas to draw all the lights, I'm planning on optimizing it since you need to load a full map to add just a few lights into it so it's not very efficient, the code is based on this tutorial and works pretty well.
All the docs are on github, if you find any bugs then please post them there or here.
Thanks for reading
Controls for the demo:
Middle mouse button to add a light.
That's all..
Light, a shadow system for LÖVE
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Light, a shadow system for LÖVE
- Attachments
-
- light.love
- DEMO
- (19.13 KiB) Downloaded 695 times
Re: Light, a shadow system for LÖVE
Wow, this works really well. Even under some stress test didn't seem to slow down. got to about 70+ lightsources until I saw fps drop.
Re: Light, a shadow system for LÖVE
This looks really nice! I noticed that this does not Work with cameras like hump. What would a solution to that be? I suspect it has something to do with the canvas. But i have never worked with the love canvas before...
Last edited by drikdrok on Wed Oct 12, 2016 7:01 pm, edited 1 time in total.
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: Light, a shadow system for LÖVE
Thanks, I'm pretty proud of the render method myself since it can handle a lot of lights before it reaches a bottleneck state. It's really efficient given that the scene canvas is small enough.whitebear wrote:Wow, this works really well. Even under some stress test didn't seem to slow down. got to about 70+ lightsources until I saw fps drop.
Yeah, light doesn't work with most camera libs.. I don't know how they work but essencialy .generateShadows() only renderes shadows to the scene that is provided, so first you need to draw your scene into a canvas instead of drawing it direcly to the screen, then pass that canvas to .generateShadows() and draw the output and the scene canvas, here's how you save thing into a canvas:drikdrok wrote:This looks really nice! I noticed that this does not Work with cameras like hump. What be would a solution to that be? I suspect it has something to do with the canvas. But i have never worked the love canvas before...
Code: Select all
function love.load()
scene = love.graphics.newCanvas()
end
function love.draw()
love.graphics.setCanvas()
love.graphics.clear()
--draw everything in here
love.graphics.setCanvas()
love.graphics.draw(light.generateShadows(scene)
love.graphics.draw(scene)
end
Re: Light, a shadow system for LÖVE
Thank you very much! I will look for a solution too !Ranguna259 wrote:Thanks, I'm pretty proud of the render method myself since it can handle a lot of lights before it reaches a bottleneck state. It's really efficient given that the scene canvas is small enough.whitebear wrote:Wow, this works really well. Even under some stress test didn't seem to slow down. got to about 70+ lightsources until I saw fps drop.
Yeah, light doesn't work with most camera libs.. I don't know how they work but essencialy .generateShadows() only renderes shadows to the scene that is provided, so first you need to draw your scene into a canvas instead of drawing it direcly to the screen, then pass that canvas to .generateShadows() and draw the output and the scene canvas, here's how you save thing into a canvas:drikdrok wrote:This looks really nice! I noticed that this does not Work with cameras like hump. What be would a solution to that be? I suspect it has something to do with the canvas. But i have never worked the love canvas before...I'll look into this after I'm done with the next update.Code: Select all
function love.load() scene = love.graphics.newCanvas() end function love.draw() love.graphics.setCanvas() love.graphics.clear() --draw everything in here love.graphics.setCanvas() love.graphics.draw(light.generateShadows(scene) love.graphics.draw(scene) end
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: Light, a shadow system for LÖVE
You are welcome, if you find anything post here or PM medrikdrok wrote:Thank you very much! I will look for a solution too !
- alberto_lara
- Party member
- Posts: 372
- Joined: Wed Oct 30, 2013 8:59 pm
Re: Light, a shadow system for LÖVE
This is actually pretty cool, terrific work!
Re: Light, a shadow system for LÖVE
I love how simple this is to use. It would be great if it worked with a camera system...to my knowledge, which is limited, I can't recall a lighting/shadow system for Love that does work with cameras. Which means there is no workaround?
Re: Light, a shadow system for LÖVE
This looks fantastic! I am making a simple arcade game without any fancy graphics. Adding some lighting may give it a less flat look.
If I use this library in my projects, is there something I should be doing to credit you for your work?
If I use this library in my projects, is there something I should be doing to credit you for your work?
- NightKawata
- Party member
- Posts: 294
- Joined: Tue Jan 01, 2013 9:18 pm
- Location: Cyberspace, Room 6502
- Contact:
Re: Light, a shadow system for LÖVE
my favorite part is that the screenshot looks like a 1990s game ad
"I view Python for game usage about the same as going fishing with a stick of dynamite. It will do the job but it's big, noisy, you'll probably get soaking wet and you've still got to get the damn fish out of the water." -taylor
Who is online
Users browsing this forum: No registered users and 3 guests