Shader presets can be an incredibly useful tool for any modeling project but they often get mistaken for material presets. In this tutorial, we will be talking about some of the different things you can use shader presets for. Let’s start things off by defining the difference between shaders and materials.
To put it simply, a material can be made up of textures and/or shaders. A texture is very often a bitmap image, projected onto the object according to a particular type of projection (cubic, spherical, UVW, etc.).
A shader is a set of fractals and mathematical functions whose final result on the object is only visible when rendered. A shader can be 2D but also 3D and thus be deployed in three dimensions (and even 4 dimensions if we animate its parameters).
However, the term “shader” is also used to name complex set-ups of materials, since the material is the result of a set of functions associated or not with textures (color, specularity, etc.).
In C4D, there are references to textures, materials, and shaders in various places in the software. It’s however difficult to make an exhaustive synthesis. Let’s try to break them down.
Materials, shaders, and texture: what are they?
- Materials: Materials determine how the surfaces of an object are rendered. The different material properties include color tones, transparency, reaction to light (matt or shiny), texture, and how it unfolds on an object, etc. The properties of a material are determined by the shader it uses.
- Shaders: Shaders are scripts that contain mathematical calculations and algorithms that allow determining the rendering of each object according to the lighting and the properties assigned to the equipment. It is the shaders that determine the properties of materials.
- Texture: Textures are bitmaps used by materials to give 3D objects their “graphic” appearance. Certain other types of textures (examples: normal map, height map, etc.) can also be used to determine other material properties (relief, reflectivity, roughness, etc.
All simple objects created directly in Unity (e.g. cube, sphere, cylinder, etc.) are assigned to the starting hardware by default. This material (Default ‐ Material) is the same for all new objects created.
It is not possible to change the appearance of the default hardware. To Change the Render Properties of an Object created in Unity, you must create a new material Menu Assets -> Create -> Material. The material created will appear in the project tab. To apply it to an object, simply drag it onto the object (directly in the scene or in the hierarchy)
More complex 3D objects are created in other software (eg Maya, Sketchup, etc.). Once imported in Unity, you will also be able to access and modify the materials that compose them.
Objects created in Unity and most imported objects will consist of materials using the standard shader. Here is a description of the main properties of this material:
In Unity, a drop-down menu allows you to change the shader of the equipment.
- Opaque: Default value. For normal solid objects without transparency.
- Cutout: Allows you to create transparency effects on the object. The particularity is that there will be zones completely opaque and areas completely transparent. No semi-transparency. (e.g.. Leaf, tree, hole in clothing, etc.)
- Transparent: Allows you to make realistic transparent and semi-transparent renderings (e.g. plastic, glass). The refractions and reflections of light will remain completely visible.
- Fade: Allows you to make transparent and semi-transparent renderings. Refractions and reflections of light will also be affected by the transparency effect.
You might have heard the word albedo if you’ve studied astronomy. The albedo is the proportion of the light that reflects so different materials have different values. But in Unity, Albedo means something different. It doesn’t mean the percentage of the light that is reflected. It sets a base color for the surface.
Albedo allows you to choose the color of the material. If the texture box (small square on the left) remains empty, the object will be the solid color chosen in clicking on the colored dot. If a texture is chosen, the color chosen will affect the tint applied to the image. (white = no tint).
Note that the transparency of the chosen color can be modified only with “transparent” and “bland” modes.
Metallic and Smoothness
These two properties allow you to adjust the reflectivity and light response of the equipment. This allows you to create more or less metallic effects (with more or less shine and reflections).
Using a normal map is one way of doing bump mapping. This is to add a second texture to an object. This second texture adds details that simulate relief (e.g. bumps, grooves, scratches, etc.).
These details will not come directly modify the mesh of the object, but they will simulate relief effects using light and shadow play. Normals maps can be created in different software (Maya, CrazyBump, etc.)
Relationship between shaders and materials in Unity
Shaders in Unity are scripts that describe the mathematical calculations required to determine what colors should be shown on the screen. It determines what color should each pixel be.
So when you see your game, it is a shader. It’s what determines what exactly you see according to the light and other settings.
Material on the other hand is what defines how a surface will be rendered or drawn on the screen. And a material has a shader associated with it. So a material has a shader and depending on the shader there will be certain options; certain parameters that you have to enter.
Some of these parameters might be the values of different colors. It could be other numbers or it could also be different textures.
A texture is simply an image; a bitmap image. And depending on the shader, the shader might require a few images. So basically, to summarize, a shader is a script that is written in a language called high-level shading language (HLSL) and that shader will require certain parameters, a certain texture. It is the material where we specify all of those things.
When we create a material, we assign a shader to it. For example, you can create a cube, create a material, and then you can assign the material to the cube.
Unity comes with a shader called the standard shader which is very flexible, robust, efficient, and multi-purpose.
Uses of a shader
Shaders make your model a lot more realistic because they calculate the behavior of light. If it is to shine, reflect like metal or be transparent like glass, you can use the corresponding shaders. These can also be mixed to create a wide variety of materials, such as magic crystals or the metallic paint of a car.
Building a shader is very easy. Select a material and switch to the “Shader” tab. At the bottom of the editing window you now have a field with building blocks, called nodes, which determine how this material should look. These nodes have labeled inputs and outputs.
So you immediately know how to connect them. You can add these with Add. Then you click on an output and drag it to an input, or vice versa to connect the nodes. There are the following types of nodes:
All of them have other subspecies that are mostly self-explanatory. These shaders can be used and combined to create the desired look. Cel shading, for example, tries to make the scene as flat as possible, as if it were a cartoon or comic instead of a three-dimensional object.
Use of shaders and textures
Shaders and textures are not only used for coloring. With them, you can control a lot more than it may first appear. Since 3D models essentially only consist of points that are connected by straight lines, rounded objects would not be possible without shaders.
Here one uses a trick. Polygons have a so-called “normal”, a vector that points out at right angles from the area of
If you compare these normals with those of the neighboring polygons, you can tell the program via the different angles that these have to the “camera” (the viewer) whether the object in this area should be rounded or angular defines a limit value.
If you set this value to 90 degrees, this means for the software, that all angles below 90 degrees represent a rounding, and values
Depending on the quality of the software, with these values, a twelve-sided surface can already appear as a perfect sphere, since the angles are less than 90 degrees. The most famous is probably the Gouraud shading. The rounding is generated by the software making the color value evenly darker on the sides facing away from the viewer using the normal angle.
A variant of this trick is often used when rendering (calculating the images) in real-time to keep the number of polygons of the models low. For a high level of detail, large numbers of polygons are required, but these require a lot of computing power and time.
The trick now is to create two models of an object. One of them is very detailed and has, for example, 20 million polygons, but the other has only 10,000. The highly detailed model is now calculated and the image is written to a special file. This converts the normals into certain colors.
If you use this image as a texture for the low-detail model, each of its polygons now has 2,000 instead of a normal one. The angular fluctuations between these normals are now used to create a shading for this simple model that corresponds to that of the highly detailed model.
Other properties that are controlled via textures and shaders include the surface structure using relief (bump), transparency, reflection, diffusion (light scattering), and highlights.
Tips and Tricks
- “Metallic” should always be 1 or 0, even if you can choose anything in between. With a few exceptions, every object is a metal or not.
- Never leave “Roughness” at 0. In real life, you can never create something 100% smooth. So the whole thing looks more realistic. Try to stay above 0.03. But of course, it’s up to you.
- With the texture nodes such as “Noise”, procedural textures, for example for stone, can be created.
- You can also use shaders to change the surface structure, so that small shadows appear when rendering. This works by feeding Color, Image, or Texture Node outputs into normal inputs.
- It’s best to just try it out, just because something looks really doesn’t mean you like it.
- If an object is too angular, you can also right-click and select “Shade smooth”.
- Of course, shaders don’t always have to be highly realistic. Cel shading, for example, aims to make the model as flat as possible and as if from a comic/cartoon.
A shader is a single material preset whereas the material is defined as having multiple materials presets. The biggest difference between the two is that shader presets can be applied to any selected surface whereas a material preset can only be applied to an item with the same name as the material preset.