OFFICIAL Using Normal Maps to Light Your 2D Game


YoYo Games Staff
YYG Staff
Check out our latest guest tech blog!

Using Normal Maps to Light Your 2D Game

PolyCrunch Games are the developers of Pyramid Plunge, a cartoony rogue-lite, action-platformer with handcrafted pixel-art. They join us on the blog to share the way they use normal maps to bring awesome lighting their upcoming game.
Using 3D shading techniques in 2D is an interesting one to create immersive environments that react to dynamic light sources. I'm using it in my game Pyramid Plunge for lighting the environment. However, I'm not using it on the characters, as I wanted to keep them looking cartoony and thus flat shaded.
You will need a simple shader that calculates shading similar to how its done in 3D, but instead of reading normal information from the 3D object or normal maps applied to 3D objects, we supply the normal maps as sprites. At the end of the article you'll find a sample project to play with.




Nice. I was messing with this the other day with good results. I'll check the blog out and see if they have some more insight or tricks.


Firehammer Games
I've done some of this in the past, though I was using TMCLux off the marketplace. The method that asset uses is slightly different than what this tutorial is doing. The tutorial is going to surfaces and such, while the asset I'm using does it straight up in a single shader that receives both texture and normal map at the same time and handles it.

And the way I've been generating normals is also as mentioned in the tutorial, using Blender. I make a model that I render as a sprite with no lighting, only color, and then I render a normal map bake. The way my setup is, I can easily do animations as well with no difficulty.