Page 1 of 1

Dyanmic lighting in Mode 7

Posted: Fri May 26, 2023 6:41 am
by pauljessup
Yupyupyup. I was messing around with the Playmat library, and thought "hey, it would be neat if I could add dynamic lighting here..." At first I tried using Luven, my go to. But because of how it handles the camera/etc, it didn't look right in Mode 7 at all. And the lights seemed to dip under the plane...no good.

But then I remembered- hey, I built a dynamic lighting library ages ago, one that could be used with tiles/etc, called SimpleLamp. I dug it back out, converted it to work with the latest iteration of Love, and viola! It works. It's great. It's a very simple idea, it calculates how much to light something based on the distance it is from a lightsource (or a lamp). So, both objects can be light by a certain %, but also individual tiles- this makes it ideal for Mode 7. I can render the tilemap with lighting separate onto a canvas, hand that canvas over to the Playmat library for displaying in Mode7, and then light each individual object, too. Looks nifty, works nice, and doesn't get slow down as long as I don't make the tiles too tiny or the maps too big.

Going to be now...cause it's late, but in the morning I plan on uploading a git repo of the latest version of SimpleLamp, with a quick example so if anyone else wants to use it, they can.
Screen Shot 2023-05-26 at 2.41.02 AM.png
Screen Shot 2023-05-26 at 2.41.02 AM.png (233.16 KiB) Viewed 2437 times

Re: Dyanmic lighting in Mode 7

Posted: Fri May 26, 2023 1:07 pm
by pauljessup
Here's the git for the library, not using a Mode7 example ATM. I'll update it with an actual readme later.

https://github.com/pauljessup/simpleLamp

Doing this in Mode7 is pretty simple...it's basically the same as the example there, but using a canvas to place your map, then the lamp:draw() overlay, then light each sprite when you add it to the sprite queue in Playmat

Re: Dyanmic lighting in Mode 7

Posted: Fri May 26, 2023 3:03 pm
by pauljessup
The original SimpleLamp code is over 10 years old now...yikes! I'm looking at it, and I'm already thinking of ways to improve it. So cool that I could get it to work with Mode7 though.

Re: Dyanmic lighting in Mode 7

Posted: Fri May 26, 2023 9:48 pm
by pauljessup
Improved the hell out of it BWAHAHA

Maybe I should release an example based on my Playmat experiments so people can see it in action. Or maybe I'll make you all wait to see the game I'm making with it first, lol