In this chapter, we will learn about materials and shaders in brief. To understand better, we will create a new 3D Project instead of our current 2D one. This will help us see the various changes.
Once you have created the new project, go to the Hierarchy and right-click, and go 3D Object → Cube. This will create a new cube in the middle of the scene. You can look around the cube by holding right-click and dragging the mouse in the Scene View. You can also zoom in and out using the scroll wheel.
Now, click on the cube, and have a look at its properties.
The bottom-most property appears to have a Default material and a Standard shader.
In Unity (and in many 3D modelling aspects), a Material is a file that contains information about the lighting of an object with that material. Notice how a gray sphere denotes the material, with some light coming in from the top.
Now, do not get confused with the name; a Material has nothing to do with mass, collisions, or even physics in general. A material is used to define how lighting affects an object with that material.
Let us try to create our own material. Right-click in the Assets region, go to Create → Material and give it a name, such as “My Material”.
These properties are not like anything we have studied so far. That is because these are properties that are programmed in the shader, not the material.
Materials are what make your objects visible in the first place. In fact, even in 2D, we use a special material that does not require lighting as well. Of course, Unity generates and applies it to everything for us, so we do not even notice it is there.
A shader is a program that defines how every single pixel is drawn on-screen. Shaders are not programmed in C# or even in an OOPS language at all. They are programmed in a C-like language called GLSL, which can give direct instructions to the GPU for fast processing.