How to use Materials in Unity?

Ouzani Abd Raouf
3 min readJun 1, 2020

Materials, Shaders & Textures

Rendering objects in Unity uses Materials, Textures and Shaders. Materials define how a surface should be rendered, using the Color tints, the Textures references, the tiling information and more. Depending on which Shader is used for a Material; you will have different options (properties) available in the inspector window.

Shaders are small scripts that contain the mathematical calculations and algorithms for calculating the Color of each pixel rendered, based on the lighting input and the Material configuration.

A Material can contain references to textures (bitmap images). The Material’s Shader uses these textures while calculating the surface color of a GameObject.

Textures can represent many aspects of a Material’s surface such as: basic Color (Albedo), reflectivity and roughness.

In addition to the built-in Shaders, you can write (or import) a custom Shader that might be more appropriate for specific configurations or special effects (for example particle effects, refractive glass, liquids, foliage or cartoony).

Materials, Textures and Shaders
Materials, Textures and Shaders

How to create a new material in Unity?

To create a new Material, use “Assets->Create->Material” from the main menu or the Project view context menu.

How to create a new material in Unity
How to create a new material in Unity
How to create a new material in Unity?

By default, new materials are assigned the “Standard” Shader, with all texture properties empty.

A new material in Unity
A new material

how to select a shader in Unity?

To select which Shader you want to use in a particular Material, click on the Shader drop-down in the Inspector, and choose one from the list.

In addition to the Standard Shader, there are other categories of built-in shaders for specialized purposes:

Shaders in unity

How to apply Materials to gameObjects in unity?

After creating the Material and selecting a Shader, you can apply it to an object and tweak all of its properties in the Inspector. To apply it to an object, just drag it from the Project View to any object in the Hierarchy window or the Scene view.

If you have applied the Material to an active object in the Scene, you will see your property changes applied to the object in real-time.

How to apply Textures to Materials?

There are two ways to apply a Texture to a property of a Material:

  • Drag it from the Project View on top of the Texture square in the inspector window;
  • Click the Select button , and choose the texture from the drop-down list that appears
How to apply Textures to Materials?
Applying Textures to Materials

If you drag a texture asset from the Project window to a gameObject in the Hierarchy window, Unity will perform the next steps for you:

  • Create a new directory named “Materials” in the Assets folder (if it does not exist yet);
  • Create a new Material (with the same name as the texture file) in this directory. The “Standard” Shader is by default assigned to this Material and the texture is applied to the “Albedo” main map;
  • Apply this new material to the gameObject.

--

--