[–] zubspace link

Light and shadows in 2D fascinates me. Even more than 3D. There are countless ways to optimizes stuff like this and, compared to 3D, you're actually able to get really atmospheric results even on low end devices. Stuff like soft shadows with shadow penumbra and antumbra are actually possible to implement with high quality without insane performance hits.

Thanks to the author for sharing the implementation step by step.

Here are some other fascinating examples of 2D light and shadow:

http://ncase.me/sight-and-light/

http://nottutorials.blogspot.ch/2009/09/dynamic-2d-soft-shad...

https://www.youtube.com/watch?v=0FZIKX1Y_8I

https://www.youtube.com/watch?v=sZxrQHIaBbE

https://www.youtube.com/watch?v=AslPHY2Bomc

reply

[–] gluelogic link

Your previous article made me remember about and subsequently purchase PICO-8. I've been hooked since then.

If anyone out there is considering buying PICO-8, go do it! It's so much fun.

reply

[–] krajzeg link

Author of the article here, glad you liked it!

To save on the wear-and-tear on your F5/Cmd+R keys, the plan is for that to happen next Thursday.

reply

[–] junke link

Thanks

reply

[–] jamesgeck0 link

Medium _does_ have RSS feeds...

reply

[–] junke link

That was a joke.

reply

[–] junke link

Really good read. Now, I am going to refresh the profile page until part 3 appears.

reply

[–] krajzeg link

It was actually precomputed at one point, but there are two things that make it less appealing. They don't feature in the article until part #3, unfortunately.

The first is flexible range - the light has adjustable brightness which makes it bigger/smaller. The second is the flickering effect applied to each line. Both these things mean that any access to the precomputed table would have to be scaled anyway, which would remove most of its benefit - to the point where all it would save would be one subtraction (sqrt() is taken from a precalculated table in the final version).

reply

[–] Scaevolus link

Could you memoize the table for each brightness? (presumably flickering is +/- brightness).

reply

[–] krajzeg link

Sure, it's possible, and flickering is indeed the same as scaling the brightness (but randomly each line). I was under the impression that the table needed would be too big, but now that I actually calculated it (max_range^2*light_levels), it's nothing back-breaking.

I'm concentrating more on the game right now than on making the engine even faster, but I'll try to look into before writing the next part - thanks!

reply

[–] Scaevolus link

PICO-8 has 1MB of Lua RAM available, is this more efficient than precomputing the light levels/breakpoints and using it for each frame?

reply

[–] planteen link

Very cool demo. I remember RPGs on the SNES looking line this. I'm guessing that the colors on this are gamma corrected. Are you doing a linear conversion then going back to a gamma corrected palette when building the fills table?

reply