2D Game Engine in C++: [8] 2D Normal Maps @s0lly
2D Game Engine in C++: [8] 2D Normal Maps  @s0lly
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!
2D Game Engine in C++: [8] 2D Normal Maps2D Game Engine in C++: [5] Alpha BlendingFirst Games in C++ - PacMan! (First Draft)Creating a Positioning System in Racing Games (as used in Krazy Karts)Raytracing in Excel - Using the GPU!AI Steering Behaviours (v8: Toggle Behaviours)Game Engine 14: Atmospheric ScatteringRaytracing - in Excel!!Project Overlay 06: Slideshows & MoreGame Engine 16: Planet-Bound CameraExcel: Endgame (Using the GPU)Animating My Logo with a Particle Simulation: Part II
s0lly |

2D Game Engine in C++: [8] 2D Normal Maps

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER