Shaders WWH : Lighting system with normalmaps using shaders? Here are the things you need.

A

AlexisTM

Guest
WHAT, WHY, HOW : Lighting system

WHAT?
First of all, you need to know what are we talking about. The lighting system is a difficult yet necessary part of your game development. The light creates the WOW effect about your game. Unless you are doing a pixel art game, you probably wants normal maps. (As well as specular map, later)

What is it? A pretty complete tutorial on what is it and how to do it (not GM specific) can be found here : https://github.com/mattdesl/lwjgl-basics/wiki/ShaderLesson6

A normal map representation:


In short; A normal map represents the "normal orientation of the surface" for your 2D sprite. It means that if your light is coming from left, and that your normal vector points towards the light, the resulting light will have more intensity than a light with an an angle to the normal vector. In the following example, the resulting intensity is simply:

Code:
resulting_intensity = lightintensity * cos(α)
In the vectorial form, it become a dot product between the light direction vector and the normal vector.



WHY?
The result of that kind of illumination is pretty neat as for example, the sprite being "normal painted" in SpriteIlluminator plus some examples.


HOW?
While making my own multi lights engine with normal maps, here are some relevant links :
 
Top