Luven - Minimalist light engine

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
ChicoGameDev
Prole
Posts: 35
Joined: Thu Feb 14, 2019 6:02 pm
Location: Switzerland
Contact:

Luven - Minimalist light engine

Post by ChicoGameDev » Thu Feb 21, 2019 6:43 pm

Hello lövers!

I'm very happy and very proud to announce my first ever open source contribution to the world : Luven !

I actually fell in love with LÖVE and Lua some month ago and started to understand lots of things that I've never understood before... So here we are : Luven v1.0 is out.

Everything you need to know is on the repo : https://github.com/chicogamedev/Luven

If you have any question, feedback, complain or else : this thread is a good place to discuss.
If you want to be kept updated on the project :
https://trello.com/b/4kLFwfyV
or
https://twitter.com/ChicoGameDev


I really hope you'll find Luven an utility, I'm sure you will. I already integrated it in my game. :ultraglee:

Image


Have a lövely day/night !


Regards
Lionel Leeser

--

Always keep Game Dev as a passion.

Yeahyay
Prole
Posts: 6
Joined: Sat Feb 23, 2019 1:58 am
Contact:

Re: Luven - Minimalist light engine

Post by Yeahyay » Sat Feb 23, 2019 2:04 am

The library works really well and is as minimal as it says; and I love it.
Would you be able to implement cone lights as well?

User avatar
yetneverdone
Party member
Posts: 351
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: Luven - Minimalist light engine

Post by yetneverdone » Sat Feb 23, 2019 3:26 am

Too bad I get low fps on my old system :(

User avatar
ChicoGameDev
Prole
Posts: 35
Joined: Thu Feb 14, 2019 6:02 pm
Location: Switzerland
Contact:

Re: Luven - Minimalist light engine

Post by ChicoGameDev » Sat Feb 23, 2019 5:29 am

Hello,
Yeahyay wrote:
Sat Feb 23, 2019 2:04 am
The library works really well and is as minimal as it says; and I love it.
Thank you for feedback ! Glad you like it !
Yeahyay wrote:
Sat Feb 23, 2019 2:04 am
Would you be able to implement cone lights as well?
Hum, it would be useful only on 2d side-scroller no ? Could you please elaborate a little bit ?

--
yetneverdone wrote:
Sat Feb 23, 2019 3:26 am
Too bad I get low fps on my old system :(
Sorry mate, I'm developing on a last-gen MacBook Pro so.... :ultrahappy:

But how bad it is actually ? Like just adding the lib completely kills your FPS ? Or have you already a small amount of FPS and the lib just kill just enough to get you bad perfs ?


Thanks for your feedback guys !


Regards
Lionel Leeser

--

Always keep Game Dev as a passion.

User avatar
yetneverdone
Party member
Posts: 351
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: Luven - Minimalist light engine

Post by yetneverdone » Sat Feb 23, 2019 9:07 am

With your example, at startup I get 4fps. When I change the size of the image to a 512x512x png, I get around 50fps.

grump
Party member
Posts: 584
Joined: Sat Jul 22, 2017 7:43 pm

Re: Luven - Minimalist light engine

Post by grump » Sat Feb 23, 2019 12:54 pm

The way this is implemented requires super beefy hardware, even without any active light sources. Reducing the maximum number of light sources (two NUM_LIGHTS constants in luven.lua) should improve fps considerably for you.

User avatar
ChicoGameDev
Prole
Posts: 35
Joined: Thu Feb 14, 2019 6:02 pm
Location: Switzerland
Contact:

Re: Luven - Minimalist light engine

Post by ChicoGameDev » Sat Feb 23, 2019 3:44 pm

Hello,
grump wrote:
Sat Feb 23, 2019 12:54 pm
The way this is implemented requires super beefy hardware, even without any active light sources. Reducing the maximum number of light sources (two NUM_LIGHTS constants in luven.lua) should improve fps considerably for you.
Yeah you are right I will work on optimization ! But if you have any suggestions I'll be happy to hear them :awesome:


Regards
Lionel Leeser

--

Always keep Game Dev as a passion.

grump
Party member
Posts: 584
Joined: Sat Jul 22, 2017 7:43 pm

Re: Luven - Minimalist light engine

Post by grump » Sat Feb 23, 2019 8:48 pm

ChicoGameDev wrote:
Sat Feb 23, 2019 3:44 pm
But if you have any suggestions I'll be happy to hear them
A simple change that would make it scale a lot better would be to have the enabled lights all at the start of the array and limit the loop in the shader to process only these lights. That way you would also get rid of that nasty if(light.enabled) in the shader that hurts performance.

There's only so much that can be done without reworking the entire simplistic design. I would render the lights as geometry into a lightmap to get decent performance with more than a handful light sources. That would also allow culling, custom light shapes and also the use of shaders for other purposes.

User avatar
ChicoGameDev
Prole
Posts: 35
Joined: Thu Feb 14, 2019 6:02 pm
Location: Switzerland
Contact:

Re: Luven - Minimalist light engine

Post by ChicoGameDev » Sat Feb 23, 2019 11:28 pm

Hi,
grump wrote:
Sat Feb 23, 2019 8:48 pm
A simple change that would make it scale a lot better would be to have the enabled lights all at the start of the array and limit the loop in the shader to process only these lights. That way you would also get rid of that nasty if(light.enabled) in the shader that hurts performance.
Yes I've already done that ! I've read that ifs like this are really bad for shaders. Thanks for pointing it out.

But that made me win only 40 fps average and when too many lights are active, if the laptop you use have no graphic card the FPS still goes down dramatically, I think I will put 32 lights by default for the moment. :ultraglee:
grump wrote:
Sat Feb 23, 2019 8:48 pm
There's only so much that can be done without reworking the entire simplistic design. I would render the lights as geometry into a lightmap to get decent performance with more than a handful light sources. That would also allow culling, custom light shapes and also the use of shaders for other purposes.
I'm really intrigued by what you're saying. And I would love to learn more about. Please if you can/want to share with me your knowledge this could be wonderful !

I actually trying to think about ways to allow culling and avoid useless calculations, but I'm afraid I'm far from having enough experience at the moment.

Thanks for your answer.


Regards
Lionel Leeser

--

Always keep Game Dev as a passion.

grump
Party member
Posts: 584
Joined: Sat Jul 22, 2017 7:43 pm

Re: Luven - Minimalist light engine

Post by grump » Sun Feb 24, 2019 8:01 am

ChicoGameDev wrote:
Sat Feb 23, 2019 11:28 pm
But that made me win only 40 fps average and when too many lights are active, if the laptop you use have no graphic card the FPS still goes down dramatically, I think I will put 32 lights by default for the moment. :ultraglee:
I use a VM that has no GPU acceleration as a "slow machine" simulator for performance testing, and your demo went from 8 fps before the change to 90 fps after the change. Still pretty slow, but I would consider 11x faster a sizable improvement.
I'm really intrigued by what you're saying. And I would love to learn more about. Please if you can/want to share with me your knowledge this could be wonderful !
For a simple lighting model like this, you can render the lights onto a Canvas, then draw that canvas on top of the game graphics using multiplicative blending. Doesn't even require a shader. The lights can be of any shape and form, like textured quads. Quick example attached.
Attachments
lights.love
(1.07 MiB) Downloaded 189 times

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests