A lowly girl named Kisa is accused of being a witch, and is sentenced to burn at the stake. The night before she is executed, a disembodied voice tells her that she must break out of the dungeon and rescue a princess in terrible danger.

Report article RSS Feed Lighting in K.I.S.A

A devlog post about the lighting engine in K.I.S.A, with a couple of reasons explaining why it's so fast.

Posted by Oracizan on Jun 27th, 2013

Kisa in moonlight and torchlight
Kisa in moonlight and torchlight.

I had it relatively easy when it came time to create the lighting engine for K.I.S.A. Because the game world is purely 2D, I didn't have to worry about normal mapping, ray tracing, or anything that ends in -ometry. Still, there are a few things about K.I.S.A's lighting engine that I find interesting enough to share.

I'm not going to get too deep into the base workings of the lighting engine, because what the engine does is very boring and common. In a nutshell: I draw gradients onto a surface (canvas for you non GameMaker folks), then render that surface over the top of the game area with blend modes.

Below are 3 lighting practices used in K.I.S.A that are not, to my knowledge, common and boring:

The lighting surface is not the size of the level. In K.I.S.A, levels sizes measure in the tens of thousands of pixels - surfaces of this size would not be feasible. Surfaces take time to draw on and take up memory just by existing, so they should be as small as possible. In this case, I made the surface equal to the size of the game window and always draw the surface at the (0,0) position on screen. When I render the lights, I offset their coordinates so that they are correctly positioned relative to the position of the game window.

Coders reading this are probably thinking "This is obvious! There's nothing special here!", but I see too many games and tutorials that make use of massive surfaces. I desperately wish that this was common and boring, because it should be.

The lighting surface is scaled. I lied earlier. The lighting surface is not the size of the game window: it's smaller.

I think that very few games require pixel perfect lighting, and K.I.S.A is not one of them. It's just not necessary. The beautiful thing about scaling is that it's not a tradeoff between quality and speed, because there is next to no sacrifice of quality. The nature of lighting usually means thatscaling does not significantly affect the quality of lighting. Lighting in K.I.S.A is all about gradients, and gradients are one of the few things that interpolated scaling handles very, very well.


The left image is 50% quality, the right is 100%. Can you tell the difference? (Click to enlarge)

In K.I.S.A, the highest quality lighting sets the scaling at 50% and the lowest at 25%. This means that the lighting surface is drawn at 25-50% size, and then stretched to fill the game window. 50% scaling is nearly indistinguishable from 100% quality, and if I did not have to worry about straight edges, which interpolated scaling does not handle well, I could afford to go much lower.

Scaling is a really simple way to speed up a 2D lighting engine, with almost no loss in graphics quality.

The lighting is not static.
 Light floods into doorways, torches flicker, etc. This is pretty common in 3D games, but I do not see it very much when I play 2D games. I'll let this final image speak for itself.


Kisa intimidates doors into opening by punching them.

Post comment Comments
babeco
babeco Jun 28 2013, 8:42am says:

wow, nice and fluid moves.

+1 vote     reply to comment
Oracizan
Oracizan Jun 28 2013, 3:17pm replied:

Thank you! We're using skeletal animation, which makes animations really smooth and memory light. I'd like to also point out that this was screen captured at 20fps, so the game proper looks about 3x smoother at 60fps.

+1 vote     reply to comment
Dahamonnah
Dahamonnah Jul 17 2013, 4:41pm says:

Wow, Amazing work. I'm thoroughly enjoying reading everything about this game because I'm a GMS user myself. I just hope there's more coverage on the game and its mechanics.

+1 vote     reply to comment
Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Icon
K.I.S.A
Platforms
Windows, Mac, Linux
Developer & Publisher
Mutant Dream
Contact
Send Message
Official Page
Mutantdream.com
Release Date
TBD
Game Watch
Track this game
News
Browse
News
Report Abuse
Report article
Related Games
K.I.S.A
K.I.S.A Indie Single Player Adventure
Related Engines
Game Maker Studio
Game Maker Studio Commercial Released Nov 14, 1999
Related Groups
Mutant Dream
Mutant Dream Developer & Publisher