
Understanding Unity Animator: State Machines & Blend Trees
February 18, 2026
Unity Shader Variant Collection Bug: Missing Shaders in Builds
February 20, 2026You bake or enable real-time shadows, and suddenly surfaces are covered in strange dark lines, speckles, or striping patterns. The lighting looks dirty or unstable, especially when the camera moves.
This issue is commonly known as Shadow Acne. It is not a texture problem. It is not a broken material. It is a shadow map precision issue.
Let’s understand why it happens and how to fix it properly.
What Is Shadow Acne?
Shadow acne appears as dark artifacts on surfaces that should be evenly lit. It happens because the shadow map cannot perfectly distinguish between a surface and its own shadow.
In simple terms, the surface ends up casting a shadow onto itself.
Why It Happens
Shadow maps store depth information from the light’s point of view. Due to limited precision, tiny floating-point errors cause the renderer to think a surface is slightly behind itself. That causes incorrect shadowing.
Common causes:
- Low shadow map resolution
- Large camera far clip plane
- Directional light covering huge areas
- Insufficient shadow bias settings
- Very thin geometry
Fix 1: Adjust Shadow Bias
Select your Light (usually Directional Light) and modify:
- Bias
- Normal Bias
Increasing Bias slightly pushes shadows away from surfaces.
Start with small adjustments:
- Bias: 0.05 – 0.2
- Normal Bias: 0.2 – 1
Be careful. Too much bias causes “peter panning” where shadows detach from objects.
Fix 2: Increase Shadow Resolution
Go to:
Edit → Project Settings → Quality
Increase Shadow Resolution to High or Very High.
Higher resolution reduces precision artifacts but increases GPU cost.
Fix 3: Reduce Shadow Distance
Large shadow distance reduces precision.
Go to:
Project Settings → Quality → Shadow Distance
Lower it to a reasonable range for your scene. For example:
- Indoor game: 20–40
- Outdoor game: 60–120
Smaller ranges improve shadow stability.
Fix 4: Adjust Camera Clip Planes
If your camera near clip plane is too small (e.g., 0.01), depth precision suffers.
Increase Near Clip Plane slightly:
- 0.1 or 0.3 instead of 0.01
This improves depth buffer precision significantly.
Fix 5: Use Cascaded Shadows Properly
Directional lights often use Cascaded Shadow Maps (CSM).
Make sure cascades are configured properly:
- 2 or 4 cascades for outdoor scenes
- Balanced cascade splits
Improper cascade setup can amplify acne artifacts at cascade boundaries.
URP and HDRP Considerations
In URP:
- Increase Shadow Resolution in the URP Asset
- Adjust Depth Bias and Normal Bias in Light settings
- Enable Soft Shadows carefully
In HDRP:
- Adjust Slope-Scaled Depth Bias
- Fine-tune Contact Shadows
Advanced Fix: Shader Offset (If Needed)
In rare cases, you may adjust rendering offsets in shaders.
Example:
Offset 1, 1
This shifts depth values slightly to reduce self-shadowing. Use carefully.
Common Mistakes
- Increasing bias too much (causes floating shadows)
- Using extremely large shadow distance
- Ignoring camera near clip plane settings
- Using very thin geometry that exaggerates precision issues
Quick Debug Checklist
- Increase Bias slightly
- Increase Shadow Resolution
- Reduce Shadow Distance
- Adjust camera Near Clip Plane
- Verify cascade setup
Is Shadow Acne a Unity Bug?
No. It is a known limitation of shadow mapping techniques used in real-time rendering. Every engine that uses shadow maps encounters this issue.
The solution is balancing bias, resolution, and distance carefully.
Final Thoughts
Shadow acne is a precision problem, not a broken lighting system. With correct bias tuning, reasonable shadow distance, and proper resolution settings, you can eliminate most artifacts without sacrificing performance.
Always adjust settings gradually and test in motion, since artifacts often appear only while moving the camera.



![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)






