What is a Material?
- Game Development course
- Intermediate
- Lesson 13/83
- 4 min
Learn that a Material defines how a surface looks.
What is a Material?
While a 3D model's geometry (Mesh) shapes its form, a Material defines how its surface appears and responds to light. All surface traits such as color, shininess, reflections, and transparency are governed through materials.
// Creating a new Material using the Standard shader
Material mat = new Material(Shader.Find("Standard"));Materials allow the very same 3D cube model to look like polished wood, rusted iron, or frosted glass.
Shader and Material relationship
Every material invariably utilizes a Shader. A shader is a program running on the graphics processor (GPU) that mathematically calculates pixel colors under lighting conditions.
// Accessing the shader used by the material
Shader currentShader = mat.shader;
Console.WriteLine(currentShader.name);The material acts as a configuration wrapper defining which colors, textures, or glossiness factors are fed into that algorithm.
Practice Print Material and Shader name
Assign "Wood" to materialName and "Standard" to shaderName. Print Material: Wood | Shader: Standard to the console.
Starter code
using System;
class Program
{
static void Main()
{
// materialName ve shaderName değerlerini tanımlayıp yazdır
}
}Sample solution
using System;
class Program
{
static void Main()
{
string materialName = "Wood";
string shaderName = "Standard";
Console.WriteLine("Material: " + materialName + " | Shader: " + shaderName);
}
}Expected output
Material: Wood | Shader: Standard
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What element defines the surface appearance and light interaction of a 3D model?
- Rigidbody component
- Material Correct answer
- AudioListener
- NavMeshAgent
Explanation: A Material is the fundamental visual asset encapsulating surface color, texture, and light reflection rules for 3D objects.
2 Instantiate a new Material
Material customMaterial = new ____(Shader.Find("Standard"));
Material customMaterial = new Material(Shader.Find("Standard"));
Explanation: In Unity, the Material constructor is called to instantiate a new material via code.
3 Material core concepts
| Term | Meaning |
|---|---|
Material |
Asset holding surface visual settings |
Shader |
GPU program calculating pixel colors |
Surface |
Outer surface interacting with light |
Mesh |
3D geometric wireframe of an object |