Löve "Light vs. Shadow" Engine v2

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
drunken_thor
Citizen
Posts: 75
Joined: Wed Oct 01, 2014 12:14 am
Location: Toronto, Canada
Contact:

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

Post by drunken_thor »

Jeeper wrote:Just a PSA to anyone who intends to use this library and is using STI, the v2 of Shadow vs light changed the way it uses canvases and does not like STI for that reason. After struggling for a long time with trying to implement this updated version to my current project, I spoke to "drunken_thor" (Who manages the library) and he confirmed that it is not compatible with STI.

The old Shadow vs Light does not have this issue however, so If you intend to use STI then I would recommend using it. A few major improvements made in this version are missing though, but I have managed to fix most of them (Such as scaling and translation, removal of shadow and light bodies etc). So if you intend to do like me and use the older version, feel free to ask for help in case you run into any issues.
Okay I worked with karai17 and he pushed a fix to STI so that it now works with this library. I also added an STI example to the examples!
Light_world.lua for all your lighting needs
Github
twitter
User avatar
Karai17
Party member
Posts: 909
Joined: Sun Sep 02, 2012 10:46 pm

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

Post by Karai17 »

Whoa, I just checked out the STI demo and I am really impressed with how it turned out! I'm glad I fixed that right away instead of sitting on it for a few weeks, ha!
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Relazy
Citizen
Posts: 51
Joined: Thu Jul 10, 2014 11:10 pm

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

Post by Relazy »

@drunken_thor, Thanks for including the examples for camera plugins! :awesome: However the translation inverted all of my camera movement(because I get the x and y of the drawn player which I use for camera movement), thankfully there is a simple fix for that:

Code: Select all

	tx,ty = love.graphics.getWidth()/(2*camera.scale), love.graphics.getHeight()/(2*camera.scale)
	tx = tx-camera.x
	ty = ty-camera.y
	LightMouse:setPosition(love.mouse.getX() - tx, love.mouse.getY() - ty)
	lightWorld:setTranslation(tx,ty)
	camera:lookAt(player.x,player.y)
Update: I found a bug(?) in the way that shadow rectangles are drawn, this bug can be replicated in the simple example. Its not related to the translations done above. Heres a gif:
Attachments
test3.gif
test3.gif (472.75 KiB) Viewed 3289 times
User avatar
drunken_thor
Citizen
Posts: 75
Joined: Wed Oct 01, 2014 12:14 am
Location: Toronto, Canada
Contact:

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

Post by drunken_thor »

@relazy is that at the edge of the screen? I know there is some problems with the range checking for screen range I just havent had the time to fix it yet.
Light_world.lua for all your lighting needs
Github
twitter
User avatar
drunken_thor
Citizen
Posts: 75
Joined: Wed Oct 01, 2014 12:14 am
Location: Toronto, Canada
Contact:

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

Post by drunken_thor »

@relazy, Okay the new code should be all fixed up, the reason I left it off was because I was initializing some shadow bodies by the center x, y and some by the topleft x, y and had to fix those first before range could be fixed
Light_world.lua for all your lighting needs
Github
twitter
giann
Prole
Posts: 42
Joined: Fri Jun 28, 2013 11:38 am

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

Post by giann »

Do you think there's room for improvements in terms of performances ?
My FPS drops really quickly the more I add bodies and lights.

Edit: Another weird issue is that FPS seems to drops relative to the screen size regardless of the number of lights/bodies.

800x450: 50fps
1280x720: 20fps
with the same number of lights/bodies
Relazy
Citizen
Posts: 51
Joined: Thu Jul 10, 2014 11:10 pm

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

Post by Relazy »

drunken_thor wrote:@relazy, Okay the new code should be all fixed up, the reason I left it off was because I was initializing some shadow bodies by the center x, y and some by the topleft x, y and had to fix those first before range could be fixed
Awesome! :awesome: Its all fixed now, thank you.

Also:
giann wrote:Do you think there's room for improvements in terms of performances ?
My FPS drops really quickly the more I add bodies and lights.

Edit: Another weird issue is that FPS seems to drops relative to the screen size regardless of the number of lights/bodies.

800x450: 50fps
1280x720: 20fps
with the same number of lights/bodies
Its not really weird that the FPS drops when increasing resolution as the number of pixels increase. The shadow bodies/light are drawn 'on screen' and not 'off screen', so any of the shadow bodies located outside of the screen area ('on screen')are not accounted for. A clear example of this is the bug I described above whereby the rectangle was considered 'off screen' when it was actually 'on screen'.

When you increase the canvas(screen) size, you increase the amount of pixels to draw and therefore performance drops as the resolution of the shadows increases which means that there are more calculations to do.

There is more to this but I don't think I have a concrete understanding of it. If any of my points are incorrect please feel free to correct them.
Last edited by Relazy on Thu Dec 11, 2014 7:18 pm, edited 1 time in total.
giann
Prole
Posts: 42
Joined: Fri Jun 28, 2013 11:38 am

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

Post by giann »

I'm aware that off screen lights/bodies are not accounted for. The numbers I gave take that fact into account.

The drop should not be that drastic in my opinion. If I can't have 3 lights and 5 bodies at 720p at 30fps minimum, this is a performance issue, not a normal occurence.
Relazy
Citizen
Posts: 51
Joined: Thu Jul 10, 2014 11:10 pm

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

Post by Relazy »

giann wrote:I'm aware that off screen lights/bodies are not accounted for. The numbers I gave take that fact into account.

The drop should not be that drastic in my opinion. If I can't have 3 lights and 5 bodies at 720p at 30fps minimum, this is a performance issue, not a normal occurence.
True, although I doubt that it's optimized enough, what machine are your running on?
I get a stable 70 fps with AMD radeon HD 6450 and a quad core 3.4 ghz processor on a resolution of 800 x 600.
giann
Prole
Posts: 42
Joined: Fri Jun 28, 2013 11:38 am

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

Post by giann »

AMD radeon HD 6350. 800x600 is fine, > 1024 is far worse.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 28 guests