How to create materials in Unity

In Unity, materials are assets that define the visual appearance of GameObjects in a scene. A material determines how light interacts with the surface of an object, which affects how it looks when rendered. It can define color, texture, transparency, shininess, and more. Materials are essential for creating realistic 3D scenes.

Here are some key aspects of materials in Unity:

  1. Shader: A shader is a script that determines how a material responds to light and shadows. Unity provides various built-in shaders, which include:

    1. Standard: This is the most commonly used shader in Unity. It is designed for realistic rendering and supports various material properties like color, metallic, smoothness, emission, and normal maps.

    2. Unlit: The Unlit Shader does not respond to lighting in the scene and is used for objects that should appear without any lighting effects.

    3. Legacy: Unity includes several legacy shaders, such as Diffuse, Bumped Diffuse, Specular, and Bumped Specular. These shaders are older and less physically based compared to the Standard Shader.

    4. Mobile: These shaders are lightweight and suitable for devices with limited GPU capabilities.

    5. Particle: These shaders are specifically designed for particle systems and allow for various particle effects, such as particles that change color over time or blend with the background.

  2. Properties: Each material can have several properties that control its appearance. Common properties include:

    1. Albedo: The base color of the material.

    2. Normal map: A texture used to simulate surface details and add depth to the material.

    3. Metallic: Determines how metallic or non-metallic the material appears.

    4. Smoothness: Controls the surface smoothness or roughness of the material.

    5. Emission: Adds self-illuminating properties to the material.

  3. Textures: Materials often use textures to enhance their appearance. Textures are images applied to the material’s properties, adding details like patterns, roughness, or shininess.

  4. Material instances: Unity allows you to create multiple instances of the same material, each with different property values.

Create materials in Unity

Materials play a vital role in defining the visual identity of your Unity project, contributing to its aesthetics and overall user experience. Here is how you can create materials.

canvasAnimation-image
1 of 25
  1. Let's create a plane and cube GameObject to demonstrate the effect of materials.

  2. Create a materials folder.

  3. Create a material in the materials folder by clicking the "+" sign and selecting "Material."

  4. Select your material, and choose a shader.

  5. Choose a color in front of Albedo.

  6. Note the difference as we change the values for the metallic and smoothness properties of the material.

  7. Let's try adding a texture to a material. Download any texture from the internet in the glTFA standard file format for three-dimensional scenes and models.. format.

  8. Create a textures folder in your project and add the downloaded textures to that folder.

  9. Create a new material. Let's add a brick texture.

  10. Open the material. In the inspector, click on the circle next to Albedo and choose your texture.

  11. With tiling, you can add more tiles of texture.

  12. To give a more in-depth texture to the material. Click on the normal map and select a texture. Notice how different textures affect the material.

  13. When you select the normal map, you might get the error "The texture is not marked as a normal map."

  14. To fix that, go back to your textures, select your texture, and change the texture type to normal map.

  15. Go back to the brick material. Next to your normal map, you can change the intensity of the material.

Creating materials in Unity allows you to bring their virtual worlds to life with rich and visually appealing textures, colors, and effects. By understanding the role of shaders and textures, you can craft materials that interact with light in realistic ways, simulating a wide range of surfaces and visual styles.

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved