Page 1 of 15

Löve "Light vs. Shadow" Engine v2

Posted: Fri Oct 24, 2014 6:49 pm
by drunken_thor
Hey everyone, So I found this http://www.love2d.org/forums/viewtopic.php?f=5&t=77418 topic a while ago and love the light engine but it didn't react well to scaling at all so I rewrote it here! https://github.com/tanema/light_world.lua

Some changes I made:
- rewrote the codebase to be much easier to extend and modify
- scaling works now
- translation works with by passing it into the draw call
- took out all the globals and love namespacing
- made the postshader independant from the project so you can use the postshader on its own but it is also nicely coupled into the light_world so you dont have to worry about canvases if you are using both
- made it easy to drop a shader into the postshaders dir and it will work with provided arguments.
- made all paths relative to the lib directory so that the folder can be placed anywhere.

Some todos I would like to do is:
- take into account rotation and shear on objects and camera.

Version 2 [RELEASE] Added new attachment to show new stuff
- I optimized how normals/shine/shadows are all drawn. They are all now drawn as an overlay instead of needing a background call and a foreground call. This should speed up the library as a whole as well.
- because of the previous point I simplified how the library is called for drawing hopefully making it more simple
- Added animations using anim8. I integrated this into the library because I need to keep track of the normal and spritesheet animations at the same time. (I will be adding documentation for this slowly but there are examples to show it off)
- Added an example of how to use the hump camera and the gamera camera.

Worked with karai17 and got STI support
- added new example to show STI functionality check out the 2.1 love file

Note Also I created this tool for my own use to generate shitty normal maps for spritesheets, also I use it to trim CrazyBump normal maps (get rid of background from spritesheets) just thought you might like to use it as well https://github.com/tanema/myspritenormaltool

Important! just published an update that will now require update to be called on your light world. This optimizes range checking of light bodies. Please see the github page for an example of how to do so. There have been significant speed optimizations though please check them out and tell me how it goes.

Re: Löve "Light vs. Shadow" Engine v2

Posted: Sat Oct 25, 2014 6:11 pm
by Jeeper
Amazing job, well done! I am sure the original author appreciates that his work lives on :)

Re: Löve "Light vs. Shadow" Engine v2

Posted: Sun Oct 26, 2014 7:22 pm
by Snuux
Awesome! More than awesome!

Re: Löve "Light vs. Shadow" Engine v2

Posted: Tue Oct 28, 2014 11:45 pm
by Nathan1852
It would also be nice if there was a way so that the top of objects isn't illuminated when the light is near them

Re: Löve "Light vs. Shadow" Engine v2

Posted: Wed Oct 29, 2014 2:52 pm
by drunken_thor
Nathan1852 wrote:It would also be nice if there was a way so that the top of objects isn't illuminated when the light is near them
Do you mean it stays dark or that the light doesnt effect it. You can do the latter by using body:setShine(false).

Re: Löve "Light vs. Shadow" Engine v2

Posted: Sat Nov 01, 2014 7:51 pm
by NeonLight_Child
Hello. Pls help with use this library. I create new light source:

Code: Select all

lightWorld = love.light.newWorld()
newlight=lightWorld.newLight(100, 100, 255, 230, 0, 30)
But how totaly remove this light source?

Re: Löve "Light vs. Shadow" Engine v2

Posted: Mon Nov 03, 2014 1:45 am
by drunken_thor
right now there is no way to remove a light but I can add that pretty easily, I will get back to you when its done.

Re: Löve "Light vs. Shadow" Engine v2

Posted: Mon Nov 03, 2014 10:57 pm
by drunken_thor
NeonLight_Child wrote:Hello. Pls help with use this library. I create new light source:

Code: Select all

lightWorld = love.light.newWorld()
newlight=lightWorld.newLight(100, 100, 255, 230, 0, 30)
But how totaly remove this light source?
I added a `remove()` method to the light world to remove any object that is already in the light world please see the wiki: https://github.com/tanema/light_world.l ... ebodylight

Re: Löve "Light vs. Shadow" Engine v2

Posted: Thu Nov 06, 2014 9:37 pm
by SNK1337
Thank you for doing this! I've been wanting to create a game with that engine for a while now, and this will probably make the process much more painless.

I'm having an issue however: Am I doing something wrong, or is the translation of the light source somehow buggy? For example, when setting it to exactly (500, 500) and moving the camera in the example "short.lua", the shadows act as if the light was stationary (meaning they stay the same when translating, which is what they're supposed to do), but the glow of the light moves with the camera. This also results into some weird bugs with the default "short.lua", since the glow and the shadows start not fitting together when pressing the arrow keys.

Re: Löve "Light vs. Shadow" Engine v2

Posted: Fri Nov 07, 2014 1:14 am
by drunken_thor
SNK1337 wrote:Thank you for doing this! I've been wanting to create a game with that engine for a while now, and this will probably make the process much more painless.

I'm having an issue however: Am I doing something wrong, or is the translation of the light source somehow buggy? For example, when setting it to exactly (500, 500) and moving the camera in the example "short.lua", the shadows act as if the light was stationary (meaning they stay the same when translating, which is what they're supposed to do), but the glow of the light moves with the camera. This also results into some weird bugs with the default "short.lua", since the glow and the shadows start not fitting together when pressing the arrow keys.
I am not sure what you are setting to 500,500. I just tried setting the conf.lua to 500,500 and it worked fine. Do you have the updated code? How are you running the project? can you post some screen shots of bugs? or post the bugs on the github issues?