【Unity】Unity Materials and Shaders Basics: Giving Objects Color and Texture

Created: 2025-12-07Last updated: 2026-07-13

The same sphere can look like gold, plastic, or rubber with a single setting change—that's the power of materials and shaders. This guide covers how the two relate, when to use Lit vs. Unlit, the three core PBR properties, a quick-reference table of material recipes, and the renderer.material pitfall.

A 3D model (mesh) is nothing more than "shape" data. The same sphere model can look like shiny gold, matte plastic, or glowing neon with a single setting change. What handles this "appearance" is the Material and the Shader.

These two concepts are closely related and often confused, but their roles are clearly different. This article covers how the two relate, how to use Unity's standard shaders (Lit/Unlit), and the basic properties of PBR (Physically Based Rendering).

Illustration of the power of materials: three identically shaped spheres side by side with completely different surfaces—metal, plastic, and glowing neon

What You'll Learn

  • The relationship between shaders (recipes) and materials (dishes)
  • When to use Lit vs. Unlit
  • The three core PBR properties: Albedo, Metallic, and Smoothness
  • Metal, wood, rubber, wet pavement—a quick-reference table of material recipes
  • Adding detail and glow with Normal Map and Emission
  • A hands-on hit flash — lighting up just the one enemy that got hit — and the renderer.material / sharedMaterial pitfalls

Sponsored

The Relationship Between Shaders and Materials

  • Shader: A program (set of calculations) that determines how an object is drawn (rendered). It defines how light is reflected, how shadows are cast, and how textures are applied.
  • Material: An asset that actually applies a shader to an object. You pick one shader, then assign concrete values to the properties that shader exposes (color, textures, smoothness, and so on).

To use an analogy, the shader is a "recipe," and the material is a "dish made by plugging ingredients into that recipe." With the same recipe (shader), changing the ingredients (property values) produces a completely different dish (appearance).

Diagram of the shader-material relationship: from a single recipe (shader), changing ingredient values produces three different dishes (materials)—a gold sphere, a red plastic sphere, and a black rubber sphere

Even if you create 100 materials—"gold material," "wood material," and so on—the recipe (shader) is often the same single Lit shader. That's what a typical project looks like.

Creating and Applying Materials

  1. Create: Right-click in the Project window and choose Create > Material. A new material asset (.mat file) is created.
  2. Apply: Drag and drop the material asset onto a 3D object in the Scene view or Hierarchy. The material is then assigned to the Materials array of the object's Mesh Renderer component.

To edit materials on a model imported from an FBX, you first need to extract them via "Extract Materials" (see the 3D model import article).

Standard Shader: Lit vs Unlit

With a material asset selected, you can choose its "recipe" from the Shader dropdown at the top of the Inspector. In Unity's Built-in Render Pipeline, the Standard shader is the default. If you're using URP (Universal Render Pipeline) or HDRP, the basics are Lit (affected by lighting) and Unlit (not affected by lighting)—the essential roles are the same.

Comparison of Lit and Unlit: when the same sphere is lit, Lit shows shading and highlights based on the light direction, while Unlit ignores the light and displays the configured color flat and unchanged
  • Lit: Fully affected by the lights in the scene. Shading changes with how light hits the surface, producing a realistic look. Most objects in 3D games use Lit shaders. This is the foundation of PBR (Physically Based Rendering) (for the light-side setup, see the lighting basics guide).
  • Unlit: Completely ignores the lights in the scene. The configured color or texture is displayed at its exact brightness. Used for UI elements, toon-style visuals, special effects, debug displays, and the like.

The decision comes down to one line: "Do you want this appearance to react to light?" If yes, use Lit; if it should always look the same, use Unlit.

Sponsored

Basic Properties of PBR (Physically Based Rendering)

Lit shaders support PBR, which simulates light reflection based on the laws of physics. Just specify the real-world characteristics of a substance, and you get a material that looks realistic in any lighting environment. The key properties to remember are essentially three, plus two.

PBR property matrix: a grid of spheres with Metallic from 0 to 1 on the horizontal axis and Smoothness from 0 to 1 on the vertical axis, showing the full range of surfaces at a glance—from matte non-metal at the bottom left to mirror-like metal at the top right
  • Albedo: The base color of the object. You typically assign a color texture (an image with the object's pattern and colors) here.
  • Metallic: How "metal-like" the surface is, from 0 to 1. 0 is non-metal (plastic, wood, fabric); 1 is metal (iron, gold, copper). You normally set it all the way to either 0 or 1—intermediate values are rarely used (because real-world substances are either metal or non-metal).
  • Smoothness: How smooth the surface is. Closer to 1 reflects light sharply like a mirror; closer to 0 is rough and scatters light. Gloss, wetness, frosted glass—this is the property that most strongly shapes the impression of a surface. Note: Unity uses Smoothness, while other environments like Unreal Engine use Roughness (= 1 − Smoothness). Same concept, just inverted.

Two more properties take the look up a notch.

Examples of Normal Map and Emission: on the left, a wall whose brick grooves look three-dimensional thanks to a Normal Map despite flat polygons; on the right, a neon sign with letters glowing via Emission floating in a night cityscape
  • Normal Map: A special texture that fakes fine surface bumps without adding polygons. Brick grooves, fabric weaves, engraved armor—"low-poly yet rich" is usually this at work.
  • Emission: Makes an object appear to emit light on its own. Used for neon signs, magical items, monitor screens, and so on. Combined with the post-processing Bloom effect, it produces a beautiful glow (see the post-processing guide).

Material Recipe Quick Reference

Here's a collection of recipes for reproducing surfaces you'll commonly need in real games, using combinations of property values. Start with these values and fine-tune the look from there.

Target SurfaceMetallicSmoothnessNotes
Gold chest / ornaments10.7–0.9Use a golden Albedo. Tune the shine with Smoothness
Mirror / chrome parts11Environment reflections (Skybox, etc.) matter for the mirror look
Plastic toy00.6–0.8A high-saturation Albedo gives it a pop feel
Wood / furniture00.2–0.4A wood-grain texture plus a Normal Map improves the feel
Rubber / tires00–0.15Barely any shine is what makes it look like rubber
Wet pavement00.7–0.9The trick is to make the Albedo darker than the dry state

As the "wet pavement" recipe shows, PBR's clarity comes from being able to translate real-world rules directly into values: getting wet = higher Smoothness and a darker color.

Hands-On: Flash Only the Enemy That Got Hit

To finish, let's touch materials from a script — the classic effect where an enemy flashes white for an instant when your attack lands. Action games, RPGs, shoot-'em-ups: they all have it. We'll build it with three enemies sharing one material.

The setup is simple. Create one Slime.mat and assign it to all three spheres (or enemy models of your choice). First, change the Albedo of Slime.mat in the Project window — all three change color at once. That's what material "sharing" really means, and it feels just as good as bulk-editing a prefab.

Comparison of what a material change affects: editing the asset changes all three enemies, while renderer.material makes only that one enemy flash white

So how do we light up only the one that got hit? Enter renderer.material.

using UnityEngine;
using System.Collections;

public class HitFlash : MonoBehaviour
{
    [SerializeField] private Color flashColor = Color.white;
    [SerializeField] private float flashTime = 0.1f;

    private Renderer rend;
    private Color originalColor;

    void Awake()
    {
        rend = GetComponent<Renderer>();
        // The first access to .material spawns a duplicate unique to this object
        originalColor = rend.material.color;
    }

    public void Flash()
    {
        StopAllCoroutines();  // So rapid hits don't stack flashes
        StartCoroutine(FlashRoutine());
    }

    private IEnumerator FlashRoutine()
    {
        rend.material.color = flashColor;
        yield return new WaitForSeconds(flashTime);
        rend.material.color = originalColor;  // Always restore the original color
    }
}

Wire up some test code (call Flash() on a clicked enemy, for instance) and only the enemy you hit flashes white for 0.1 seconds while the other two stay blue. On first access, renderer.material automatically creates a material duplicate unique to that object, so you can touch it safely without affecting the shared original — that's the mechanism behind this effect.

Break It on Purpose, Then Fix It

  1. Change material to sharedMaterial: hit one enemy and all three flash white. Worse is the editor aftermath: sharedMaterial rewrites the Slime.mat asset itself, so it stays white after you stop Play — and Ctrl+Z won't help. When "the color didn't come back after I stopped," this is almost always the culprit
  2. Scale up to 30 enemies: renderer.material spawns one duplicate per enemy. Thirty enemies means thirty duplicates — each a separate material, which hurts draw batching. At a few dozen it rarely matters, but for games that flash large crowds, there's MaterialPropertyBlock, a mechanism that avoids duplicates entirely. Which is faster depends on your setup, so measure with the Profiler and Frame Debugger before switching

After stopping Play, take one look at Slime.mat — still its original color? The three enemies share a single asset, and only the one you hit flashes and recovers. Once you can confirm that, you've got the etiquette of touching materials from code.

Bonus: Good to Know for Later

Once you start working with materials, these are topics worth knowing early to avoid accidents.

  • Pink material = missing shader: If a shader doesn't match your project's render pipeline (Built-in/URP/HDRP), the material turns shocking pink. The differences between pipelines and how to convert are covered in the render pipeline article.
  • Build custom shaders with Shader Graph: Unique looks like "dissolve effects" or "holograms" are the world of Shader Graph, where you build shaders by connecting nodes. Now that you have the PBR basics down, it should be an easy entry point.

Summary

Materials and shaders are essential elements for bringing 3D objects to life.

  • The shader is the "recipe," and the material is the "dish made from the recipe." One shader can spawn countless materials.
  • Lit reacts to light; Unlit ignores it. Choose based on "should this react to light?"
  • The PBR fundamentals are Albedo (color), Metallic (metal or not, 0 or 1), and Smoothness (the star of surface feel).
  • Use Normal Map for detail without extra polygons, and Emission for self-illumination.
  • When in doubt, start from the values in the material recipe quick reference.
  • To change one object, use material; sharedMaterial changes everyone — and the asset itself. If a color won't revert after stopping Play, suspect the latter.

Good materials dramatically boost the believability of your game world.