
Unity Trigger Bug: OnTriggerStay Inconsistent Behavior (Causes and Reliable Fixes)
February 11, 2026
Unity ScriptableObject Bug: Data Resetting During Play Mode
February 11, 2026A common issue in Unity 2D projects using the Universal Render Pipeline (URP) is that normal maps do not appear to work correctly with 2D Lights. Developers often report that:
- Sprites look flat even with normal maps assigned
- Lights do not react to surface detail
- Normal maps appear inverted or broken
- Lighting works in Scene view but not in Game view
This problem is usually not a Unity engine bug, but a configuration mistake in URP, materials, textures, or light setup. In this guide, we will explain the real causes and how to fix them properly.
Understanding How 2D Lighting Works in URP
Unity’s 2D lighting system works only when:
- You are using Universal Render Pipeline (URP)
- The project uses a 2D Renderer
- Sprites use a 2D Lit material
- Normal maps are imported correctly
If any of these requirements are missing, normal maps will not affect lighting.
Problem 1: Using the Wrong Material
The most common reason normal maps do not work is using the wrong sprite material.
If your sprite uses:
- Sprites/Default
- Any Unlit shader
Normal maps will not respond to lights.
Correct solution:
- Change material shader to Universal Render Pipeline / 2D / Sprite-Lit-Default
This shader supports 2D lighting and normal maps.
Problem 2: Project Not Using 2D Renderer
Even if URP is installed, your Renderer asset must be set to 2D Renderer.
Fix:
- Open Project Settings → Graphics
- Assign URP Pipeline Asset
- Inside URP asset, ensure Renderer is set to 2D Renderer
If using Forward Renderer, 2D normal maps will not behave correctly.
Problem 3: Normal Map Imported Incorrectly
Normal maps must be imported properly, or Unity will treat them like regular textures.
Correct import settings:
- Texture Type: Default
- Check Create from Grayscale if needed
- Or set Texture Type to Normal Map
- Disable sRGB (Color Texture) for normal maps
After changing import settings, click Apply.
Problem 4: Normal Map Not Assigned to Secondary Texture
In Unity 2D, normal maps must be assigned as a Secondary Texture in the Sprite Editor.
Fix:
- Select the sprite texture
- Open Sprite Editor
- Click Secondary Textures
- Add a texture named NormalMap
The name must match exactly: NormalMap.
Problem 5: Light Type Does Not Support Normals
Only certain 2D light types support normal maps:
- Point Light 2D
- Freeform Light 2D
- Spot Light 2D
Global Light 2D does not create visible normal map shading differences.
Problem 6: Normal Map Strength Too Weak
Sometimes the normal map is working, but the effect is subtle.
Increase:
- Light Intensity
- Normal Map Distance
- Normal Map Quality in URP settings
Also test with exaggerated normal maps to confirm it is functioning.
Problem 7: Z-Axis or Sorting Layer Issues
2D lights operate within specific sorting layers and blending styles.
Check:
- Sprite sorting layer matches light’s target sorting layers
- Z positions are consistent
- Light’s Blend Style supports normal maps
Problem 8: Camera Not Using URP Renderer
If lighting works in Scene view but not Game view, the camera may not be using the correct renderer.
Fix:
- Select Camera
- Ensure Renderer is set to your 2D Renderer
Problem 9: Shader Graph Custom Shader Missing Normal Support
If using Shader Graph, make sure:
- The graph is set to Sprite Lit target
- A Normal input node is connected
- Surface type supports lighting
If not, normal maps will not affect lighting.
Quick Debug Checklist
- Are you using URP?
- Is Renderer set to 2D Renderer?
- Is the material Sprite-Lit-Default?
- Is the normal map imported correctly?
- Is the normal map assigned as Secondary Texture?
- Is the light type correct?
- Are sorting layers matching?
Professional Best Practice
For production-quality 2D lighting:
- Use Sprite-Lit-Default or custom 2D Lit Shader Graph
- Keep consistent normal map direction (OpenGL style)
- Test lighting with extreme light angles
- Use properly authored normal maps, not auto-generated grayscale maps
Conclusion
Unity 2D normal maps not working correctly is usually caused by incorrect URP setup, wrong material selection, improper import settings, or misconfigured light components. Once the project is correctly configured with a 2D Renderer, Sprite-Lit material, properly imported normal maps, and supported light types, the system works reliably.
Understanding how Unity’s 2D lighting pipeline operates is key to avoiding this issue and achieving professional-quality 2D lighting results.




![Lighting in Unity: A Practical Guide for Game Developers There’s something satisfying about watching a flat, boring plane turn into a mountain range. That’s exactly what a height map does in Unity. With a simple grayscale image, you can shape landscapes, add depth to materials, and create worlds that feel real instead of flat. It’s one of those tools that looks technical at first, but once you understand it, it becomes surprisingly simple and powerful. In this guide, we’ll break down what a height map is, how it works in Unity, how to use it for terrain, how it differs from normal maps, and how to control it with C#. What Is a Height Map? A height map is a grayscale image where each pixel represents elevation. Black = lowest height White = highest height Gray = values in between Think of it like a topographic map, but simplified into brightness levels. Unity reads this image and uses the brightness values to push parts of a surface up or down. The result? Hills, valleys, cliffs, and surface details created from a simple image. Height Maps in Unity Terrain The most common use of height maps in Unity is terrain generation. Unity’s Terrain system allows you to import a height map and automatically generate a 3D landscape from it. How to Import a Height Map into Terrain Create a Terrain: GameObject → 3D Object → Terrain Select the Terrain object. Open the Terrain Inspector. Choose Import Raw under the heightmap settings. Select your grayscale RAW file. Once imported, Unity converts the grayscale values into elevation data. If your height map is smooth, you’ll get rolling hills. If it has sharp contrast, you’ll get steep cliffs. Height Map Resolution Matters Resolution affects how detailed your terrain will be. A low-resolution height map creates blocky terrain. A high-resolution height map creates smoother, more detailed landscapes. However, higher resolution also increases memory usage and processing cost. If you're building for mobile, balance detail with performance. Height Maps vs Normal Maps This is where many beginners get confused. Height Map Actually changes geometry (in terrain or displacement). Creates real depth. More performance cost if geometry changes. Normal Map Does NOT change geometry. Fakes lighting to simulate bumps. Much cheaper performance-wise. If you need real terrain shape, use a height map. If you just want surface detail like cracks or scratches, a normal map is usually better. Using Height Maps in Materials (Parallax & Displacement) Height maps are not limited to terrain. You can also use them in materials. In Unity’s Standard Shader (or URP/HDRP equivalents), height maps can be used for: Parallax Mapping – creates depth illusion without changing geometry. Displacement Mapping – actually modifies mesh vertices (HDRP). For example, if you apply a brick texture, adding a height map can make the mortar appear recessed and bricks raised. Creating Height Maps You can create height maps using: Photoshop or GIMP (grayscale images) Blender (baked displacement maps) World Machine or Gaea (terrain generation tools) Procedural generation with code The key is keeping it grayscale and avoiding compression artifacts. Generating a Height Map with Code You can also generate terrain procedurally using Perlin Noise. This is common in open-world or survival games. Here’s a simple example: [csharp] using UnityEngine; public class TerrainGenerator : MonoBehaviour { public Terrain terrain; public int depth = 20; public int width = 256; public int height = 256; public float scale = 20f; void Start() { terrain.terrainData = GenerateTerrain(terrain.terrainData); } TerrainData GenerateTerrain(TerrainData terrainData) { terrainData.heightmapResolution = width + 1; terrainData.size = new Vector3(width, depth, height); terrainData.SetHeights(0, 0, GenerateHeights()); return terrainData; } float[,] GenerateHeights() { float[,] heights = new float[width, height]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { heights[x, y] = Mathf.PerlinNoise(x / scale, y / scale); } } return heights; } } [/csharp] This script generates a terrain using Perlin Noise, which creates natural-looking hills and variation. Controlling Height Strength Sometimes height maps look too extreme. Other times they look flat. In terrain settings, you can adjust: Terrain height (Y scale) Brush strength (when sculpting manually) In materials, you can adjust height intensity inside the shader settings. Small adjustments make a big difference. Subtle depth often looks more realistic than exaggerated displacement. Common Problems and Fixes Terrain Looks Blocky Increase heightmap resolution or smooth the terrain. Edges Look Stretched Make sure your height map is square and uses proper dimensions (like 512x512 or 1024x1024). Lighting Looks Strange Check your normal settings and ensure lighting is baked or set correctly. When to Use Height Maps Use height maps when: You need large landscapes. You want realistic terrain shaping. You’re building procedural worlds. You need true geometric depth. Skip them when: You only need small surface detail. Performance is extremely limited. Final Thoughts Height maps are one of those tools that feel technical at first, but once you use them, they become creative tools. You’re not just editing numbers. You’re sculpting mountains. Carving valleys. Designing the shape of a world. Start simple. Import a grayscale image. Adjust the scale. Play with noise. Watch how small changes affect the landscape. Once you understand height maps, Unity stops feeling like a flat engine. It starts feeling like a world builder.](https://unityqueen.com/wp-content/uploads/2026/02/Lighting-in-Unity-150x150.jpg)





