2D Dynamic Lighting with Normal Maps: Principles and Practice

    Normal maps let flat 2D sprites respond convincingly to moving light sources by encoding surface orientation into color. This article explains why point lights alone can't produce convincing lighting on flat art, how normal maps store direction data in the RGB channels, how to derive a normal map from a height sketch instead of guessing from color, and how to integrate and roll out the technique safely. It also sets realistic expectations for what normal maps can and cannot do, and offers practical guidance on choosing a 2D engine.

    2D Dynamic Lighting with Normal Maps: Principles and Practice

    1. Where the Problem Starts: Why Lighting Always Falls a Bit Short

    In indie game production, art assets tend to get reused over and over. Put the same wall or wooden crate into two different ambient conditions—a town in daylight versus the dim glow of a cellar—and the mood shifts instantly. That’s ambient lighting doing its job: cheap to implement and clearly rewarding. But the moment you want more detail—say, a flashlight sweeping across the crate so that the raised frame, the diagonal braces, and the recessed panel seams each produce their own gradient of light and shadow—adjusting colors alone simply won’t cut it.

    The root cause is missing information. An ordinary bitmap records only “what color each pixel is”; it says nothing about “which way this surface is facing.” When the light direction changes, the engine has no way to decide which side should get brighter and which should get darker, so the highlights and shadows already painted into the image stay frozen in place, disconnected from the scene. To clear this hurdle, you need to give the engine one more dimension of information: surface orientation. That is exactly the problem normal maps solve.

    2. Where the Limits of Flat Lighting Lie

    Start with the most basic approach: placing a 2D point light in the scene. Its behavior is intuitive—it illuminates nearby walls and crates, the lit region follows the light as it moves, and it can represent the range, color, and falloff distance of the light. As far as “where the light is,” that’s already enough.

    Take the cellar crate as an example. Put the light on the left, and the left half of the crate brightens while the right half stays relatively dark. But if the only thing the engine has is the original color image, it can’t tell which line is a raised structure and which line is a recessed seam. The highlights and shadows already painted into the source image won’t automatically flip as the light direction changes. The result: the lit area follows the light, while the crate’s own sense of volume doesn’t react at all. This is the fundamental limitation of flat lighting—it handles the “distribution of illumination,” not the “surface’s response to light.”

    3. Normal Maps: Using Color to Record Which Way a Surface Faces

    Normal maps usually appear in blue-purple tones. This isn’t an arbitrary color choice but a form of vector encoding: each pixel’s RGB value corresponds to a 3D normal direction, telling the engine which way the surface at that point faces and how much it tilts.

    • R channel: facing left or right (X axis)
    • G channel: facing up or down (Y axis)
    • B channel: facing the viewer (Z axis, usually high and close to 1, meaning “facing the camera”)

    With direction information in hand, when the light moves from the left side to the right, surfaces facing the light and surfaces facing away can receive different brightness. The same edge in the same image now shows a genuine transition as the light position changes. Decoding and lighting calculation are standard practice in any general graphics pipeline. Conceptually, it looks like this:

    1. // 1. Decode: turn [0,1] colors back into [-1,1] direction vectors
    2. vec3 n = texture(normalMap, uv).rgb * 2.0 - 1.0;
    3. n = normalize(n);
    4. // 2. Compute the direction from the current pixel to the light source
    5. vec3 lightDir = normalize(lightPos - pixelPos);
    6. // 3. Lambertian diffuse: the more directly a surface faces the light, the brighter it gets
    7. float diffuse = max(dot(n, lightDir), 0.0);

    The key is dot(n, lightDir) (the dot product of the normal and the light direction): when the surface faces the light directly, the dot product approaches 1 and the surface is brightest; when it’s perpendicular, the value approaches 0; when it faces away, it’s clamped to 0 and the surface is darkest. Because the normals are computed per pixel, the edge of the crate’s diagonal brace and both sides of each seam can each show their own brightness, and that’s where the sense of volume comes from.

    4. From Height Sketch to Normal Map: Workflow Matters More Than Tools

    A normal map isn’t “another lighting image”—it’s a re-expression of geometry. The most reliable way to produce one is to first establish a sense of height, then derive the directions from it. Taking the cellar crate as an example, you can understand its relief by thinking in structural layers:

    1. Frame and diagonal braces: clearly raised (high);
    2. Panel surfaces: relatively flat;
    3. Panel seams: recessed inward (low).

    First draw this “height sketch” clearly, then derive the normals from the height differences. Conceptually, the derivation looks like this:

    1. // Estimate slope from the height difference of neighboring pixels
    2. // (conceptual example; strength controls the depth of the relief)
    3. float hL = height(x - 1, y);
    4. float hR = height(x + 1, y);
    5. float hU = height(x, y - 1);
    6. float hD = height(x, y + 1);
    7. vec3 n = normalize(vec3((hL - hR) * strength, (hU - hD) * strength, 1.0));

    Here’s an easy trap to fall into: you must not estimate height from color alone. Dark wood grain, stains, and shadows already painted into the source image will all be mistaken for “grooves” by a faulty algorithm, leaving patches of pits that don’t actually exist on the normal map. The correct approach is to let “what should be raised is raised, and what should be recessed is recessed” be driven by structure, keeping texture patterns separate from real relief.

    5. Applying It Correctly: Pilot Locally, Then Roll Out Gradually

    At the integration level, most engines that support 2D lighting let you reference both the source image (albedo) and the normal map at the same time in the material or texture container, with no need to overwrite the original image. This makes iteration safe: you can switch the normal map off at any time for an A/B comparison.

    When rolling it out, follow a “validate on a small scale before expanding” principle, especially when you use intelligent coding tools or an AI agent to generate normal maps in bulk:

    • Give the structure first, then let the tool work. Don’t let the tool “guess from colors.” Instead, you first mark which regions are raised, which are recessed, and how the seams recede, then let the tool generate accordingly.
    • Do one object at a time. Rather than throwing the entire game’s assets at it, pick a single wall or crate as a template, tune parameters repeatedly until you’re satisfied, then copy that workflow to similar assets.
    • Control variables when comparing. Keep the same source image, the same light, and the same light-sweep path, toggle only the normal map on and off, and disable shadows and extra reflections—that way you can see the normal map’s own contribution clearly.

    An example agent instruction you can use:

    1. Generate a normal map from this crate texture, following these constraints:
    2. 1. The outer frame and diagonal braces are raised structures, the panels are the base plane, and the seams are recessed inward;
    3. 2. Wood grain and stains are surface coloring—do not treat them as geometric recesses;
    4. 3. Output a blue-purple normal map with moderate strength, preserving structural edges rather than texture detail;
    5. 4. Attach the height sketch so I can verify it.

    6. Don’t Hold Unrealistic Expectations for Normal Maps

    A normal map is a “response optimization for light,” and it has a few boundaries you must be clear about:

    • It won’t turn the crate into real 3D. The object is still a flat sprite; the normal map only makes the flat surface “look like it has relief” under lighting.
    • It doesn’t change the silhouette. The outline and outer shape stay exactly the same; the raised effect shows up only in brightness.
    • Adding it doesn’t automatically make things brighter or better-looking. Because regions facing away from the light get correctly darkened, the overall average brightness may even drop. Whether it fits should be judged by the scene’s goals, not by a blind “more volume is always better.”

    7. Additional Thoughts on Choosing an Engine

    Let’s return to a question many people start with: how do you pick a development engine when making an indie game? For the kind of 2D dynamic lighting discussed here, what really determines feasibility isn’t any specific product but whether the engine has three general capabilities: support for 2D dynamic light sources, support for referencing a normal map at the material layer, and the ability to customize shaders to extend lighting logic. Most mainstream 2D game engines cover these. So rather than being led around by a single feature checklist, it’s better to weigh things holistically—project size, the team’s familiarity with the language and ecosystem, cross-platform publishing needs, and the cost of the asset pipeline and collaboration. Lighting is just one piece of the puzzle: tools serve the goal, and the goal doesn’t bend to accommodate the tools.

    8. Summary

    Going from “flat lighting” to “normal-map lighting” is essentially about filling in the missing dimension of “surface orientation” for 2D assets. The practical path can be summed up in four steps: understand the limits of point lights → build structure with a height mindset → correctly derive normals from that structure → pilot locally and compare scientifically before rolling out. Keep three principles in mind—“structure determines relief, texture doesn’t equal a recess, and a normal map doesn’t equal 3D”—and you can trade a unified set of assets for dynamic lighting that is credible, controllable, and full of atmosphere, even with limited art resources.