Shädows (A light engine)

Showcase your libraries, tools and other projects that help your fellow love users.
Starkkz
Prole
Posts: 24
Joined: Thu Jul 16, 2015 7:24 pm

Shädows (A light engine)

Post by Starkkz »

Hello, I'm here to share my dynamic shadows and lights library. This is pretty comparable to Light vs Shadows by PriorBlue, since most of the code was inspired from it. Except that this one has major optimizations in it's code.



Repository
https://github.com/Starkkz/shadows
Wiki
https://github.com/Starkkz/shadows/wiki
Issues
https://github.com/Starkkz/shadows/issues

I'm open to receive feedback and code contributions to the repository.
Attachments
demo.love
(543.3 KiB) Downloaded 721 times
Last edited by Starkkz on Sun Jan 07, 2018 12:15 pm, edited 8 times in total.
User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: Shädows (A light engine)

Post by airstruck »

Can you post a small demo? I'd like to try it out :)
Starkkz
Prole
Posts: 24
Joined: Thu Jul 16, 2015 7:24 pm

Re: Shädows (A light engine)

Post by Starkkz »

Here you go.
https://github.com/Starkkz/shadows/wiki ... onstration
https://github.com/Starkkz/shadows/wiki ... onstration

It's supposed to do the same, the first example uses a love.physics world and the second one are plain Lua functions from the library.
asmageddon
Prole
Posts: 13
Joined: Mon Apr 09, 2012 1:39 pm

Re: Shädows (A light engine)

Post by asmageddon »

Hey, I played with it a bit, definitively looks nice - though I'm not a fan of the filters you include by default, tbh.

I tried playing around with the, ahem, bodycount, and on my moderately powerful PC, with 40 static + 40 dynamic bodies, the FPS dips below 60 FPS at around 20-22 lights - not awful, but not that great. The first observation that comes to mind is that you recalc lights when the scene changes, regardless of whether the changes occur within their radius, it'd be nice to see that optimized out.

Another thing I can't help but note - are the mild halos around shadows if I turn the filters off - what are those, and where do they come from?

Also, a feature I'd like to request - "infinite" length shadows, e.g. not ending a certain distance after an object. And, while it's not crucial, it'd be nice to have (optional, of course) soft shadows.

Either way, thanks for the great lib :)
Starkkz
Prole
Posts: 24
Joined: Thu Jul 16, 2015 7:24 pm

Re: Shädows (A light engine)

Post by Starkkz »

I applied some optimization filters, could you try it again?
What do you mean by mild halos, could you show me some screenshots?
I could implement a 'infinite' length canvas for multi-use inside the light engine, although it may be a bit complex.

I'm unable to make soft shadows, I already tried and got several failures.
Edit: I've read some articles about how you calculate the shadow fins, but there's a problem with that, how do you actually calculate the shadow fins of a circle or a shadow with a specific height (like the ones from the demo)?

This is how it would actually look.
Image
Starkkz
Prole
Posts: 24
Joined: Thu Jul 16, 2015 7:24 pm

Re: Shädows (A light engine)

Post by Starkkz »

I seem to have achieved softer shadows but my shader script isn't somewhat amazing so I'm probably going to need a little bit of contributions in there.
Image
asmageddon
Prole
Posts: 13
Joined: Mon Apr 09, 2012 1:39 pm

Re: Shädows (A light engine)

Post by asmageddon »

Halo: https://love2d.org/imgmirrur/BbUE2MS.png

Btw, you should probably do soft shadows not with shaders, but with polygons, texturing the penumbra with a gradient triangle, at least that's how I've seen it done.
Starkkz
Prole
Posts: 24
Joined: Thu Jul 16, 2015 7:24 pm

Re: Shädows (A light engine)

Post by Starkkz »

That's the bloom effect. About the polygons, maybe I could use a textured Mesh.
Starkkz
Prole
Posts: 24
Joined: Thu Jul 16, 2015 7:24 pm

Re: Shädows (A light engine)

Post by Starkkz »

Alright, after trying to use polygons to solve this out desperately I ended up realizing that the shadow's image was being eaten by the light's shadow'd area. So in order to get a corrected soft shadow I had to use a multiply blending mode, basically I changed a little piece of the code and I think it looks much better.
Image

And this is with all the shaders deactivated, except for the penumbra shader.
Image
asmageddon
Prole
Posts: 13
Joined: Mon Apr 09, 2012 1:39 pm

Re: Shädows (A light engine)

Post by asmageddon »

I think it looks good, though the lights look a bit odd when they add up to that bright blotch. I guess that's more of a problem for HDR than anything else, though.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests