Uploaded January 2019 | Updated September 2026, 2 hours ago
This video demonstrates 2D Normal Maps - a technique used to create directional lighting / shading based on the relative location of a "LightSource" to the drawn object in question. The end effect produces shading which gives even more of a 3D effect to the graphics engine.
The process that I've used to do this is to create two versions of the tree sprite, one being the simple sprite, and another image (which I call the "normal map") which is exactly the same as the original sprite, but with its red, green, and blue colours changed. These are changed to represent the intensity of light that should impact the sprite depending on the direction of the "LightSource". These three colour channels represent horizontal (x-axis), vertical (y-axis) and depth (z-axis) coordinates respectively.
For example, a normal mapping of the sprite will have a red colour of 255 (the maximum) if the light intensity is brightest when a light is to the extreme right of the object. So, for the tree, this would be the right hand side of the tree trunk, and any right hand side of the individual leaves. The opposite can then be done for the left hand side of the tree. This gives a nice shading effect to the tree depending on where the light is coming from - although the lighting can be a bit "blocky" given that we are working on very low-res images!
I will release all code on GitHub once I've finalised the engine - and have nice looking code to boot!
Using the Chili Framework: http://wiki.planetchili.net/index.php... - thanks Chili!
This video demonstrates 2D Normal Maps - a technique used to create directional lighting / shading based on the relative location of a "LightSource" to the drawn object in question. The end effect produces shading which gives even more of a 3D effect to the graphics engine.
The process that I've used to do this is to create two versions of the tree sprite, one being the simple sprite, and another image (which I call the "normal map") which is exactly the same as the original sprite, but with its red, green, and blue colours changed. These are changed to represent the intensity of light that should impact the sprite depending on the direction of the "LightSource". These three colour channels represent horizontal (x-axis), vertical (y-axis) and depth (z-axis) coordinates respectively.
For example, a normal mapping of the sprite will have a red colour of 255 (the maximum) if the light intensity is brightest when a light is to the extreme right of the object. So, for the tree, this would be the right hand side of the tree trunk, and any right hand side of the individual leaves. The opposite can then be done for the left hand side of the tree. This gives a nice shading effect to the tree depending on where the light is coming from - although the lighting can be a bit "blocky" given that we are working on very low-res images!
I will release all code on GitHub once I've finalised the engine - and have nice looking code to boot!
Using the Chili Framework: http://wiki.planetchili.net/index.php... - thanks Chili!
![2D Game Engine in C++: [5] Alpha Blending
This video illustrates an useful addition to the planes concept, that being alpha blending / transparency.
Critically, this will allow effects such as clouds in a top down / isometric game, see-through ghosts in a side-scrolling game, or smoke (as displayed here) in any type of game. It could also allow for effects such as creating see through areas of closer planes to make sure that the playing area is still visible.
I will release all code on GitHub once Ive finalised the engine - and have nice looking code to boot!
Using the Chili Framework: http://wiki.planetchili.net/index.php... - thanks Chili! 2D Game Engine in C++: [5] Alpha Blending](https://i.ytimg.com/vi/kF2RAxFV7qs/mqdefault.jpg)









