Thursday, November 21, 2013

Normal Maps and Dynamic Lighting in Construct 2

Normal Maps applied to sprite are in Construct 2. Light on the Left, Light on the Right respectably.
Oh what have I gotten myself into.  While I was thinking about the redesign of my character, I started mulling over some old ideas that I had for rendering.  When I was first thinking about the game, I played with the idea of using normal maps to simulate a light source on my character.  I think I have it figured out and am about to start making it a part of my regular work flow.

Go here to download the plugin for Construct 2: 2D Dynamic Lighting by Pode

If you don't know what "normal maps" are, its basically an image with color information that can help the computer render the shape based on the colors.  So you can take what was a high polygon model, drop the number of polygons, lay a normal map on it, and the computer can render fine detail and simulate the shape based on the color information.  You can find more information HERE

My idea was to simulate that with very flat coloring.  I know that blue is the left side of a model and magenta is the right side of a model, so why can't I just use that for the coloring.  I'll have my normal drawing without shading and then a separate drawing that will just have the shape information (the normal map).  The light areas will be magenta and the shadow area will be blue.  That alone will let the shadow flip when the character turns.

The best part is Toon Boom (and Flash) have pallet swapping features.  So I can paint my character normally, render the animation, then go in and change all of the shadows to blue and other areas to magenta with relative ease.

I'm pretty excited about the implementation with only a few questions.  1) I know how to adjust the light, but I'm not totally sure what the parameters mean by themselves.  I think the positions are based on the layout, but I'm not sure.  2) I'd love to be able to give the shadow a little color instead of just darkening the area.  I've been using a cool blue shadow in the backgrounds and would love to carry that over.
3) Last, I'd like to use this for enemies and civilians.  Can I spawn an enemy with its corresponding normal map and have it line up and animate correctly?  There are containers in Construct 2 now so that might be the best way to go.

I'll will post any further developments on the blog.


  1. Do you still use normal maps for dynamic lighting? How has your experience been so far?

    1. Hi Holden. I haven't had a chance to implement it soon, but plan on doing a video tutorial in the near future. I've rethought how I will be doing it since writing this post though. Rather than using the light source and plugin, I'm just going to use an overlay filter and swap the colors as the player turns. That way I can control the color of the light and shadows. The only problem I'm working on now is wether to have each "overlay" sprite right above the character art, or if I have all of the overlay sprites on their own layer. If I do that, I have to figure out how to match the z-depth on both the original art layer and the overlay layer. If you read through all of that, then I commend you. Let me know if you have any questions.