Brief Consideration About Materials
I originally made this tutorial for a lecture I gave at CCAA, a school in Brazil where I help to run the Post-Graduation course in Game Art. It came from the need to explain some elements of the materials that are commonly misunderstood. Especially about Specular maps which, sometimes, seem to be a bit confusing for some people.
Most artists, in general, have a pretty good understanding of Diffuse, Normal and Alpha maps, but it's often on the Specular map that they will get lost and sometimes even ruin a pretty good asset.
I hope you enjoy this tutorial.
Textures & Shaders
If the shape of an object, in 3D, is the result of its geometry, the material from which this object is made of is the result of its shader and textures. Shaders are instructions that tell the render how an object should be displayed. Textures are images that provide visual information to the shader. They can be extracted from real life photographs, they can be digital paintings, or even procedurally generated (Fig.01).
In this way, we use textures as inputs of a shader, defining attributes such as color, reflectivity, transparency, roughness, brightness and other characteristics of a possible material. Out of these textures, the most common are:
- Specular (and Specular Power - aka Glossiness)
Normals Maps will change the normals of a given surface. They will make the light bounce off the surface as if it had hit something other than just the polygons.
Alpha Maps define transparency. It can be on materials such as water, glass, fire, smoke... Or it can also be used for creating different silhouettes, gaps and rips on simple surfaces (Fig.02).
So, in some ways, if we disregard the truly transparent or translucent materials, like glass, where the transparency is at the core nature of the material, it would be ok to say that Alpha and Normal maps alter how we see the shape of an object more than the material itself.
Self-Illumination or Glow only defines parts of the object that emits light; that glow in the dark (Fig.03). Thus, transparency, embossing and brightness are material characteristics conferred by the respective use of the following maps: Alpha, Normals and Self-Illumination.
But what about all the other aspects? Those that really define the nature of a material. Is it light or dark? Smooth or rough? Clean or dirty? Reflective or matte? It is made of metal, clay, wood or plastic? Is it wet or dry? Rusty? Stained? Scratched? Old and worn, or brand new? All these variables, and many more, are controlled by two maps: Diffuse and Specular (well, maybe three maps, since there's still the Specular Power. But because this one only affects the specularity, I'll consider it as part of the Specular slot).
But what are they? Everyone who works with 3D has at least a basic understanding that Diffuse is the color of an object and Specular is the light reflected on its surface... the highlights. But this definition is somewhat simplistic. We must remember that everything we see around us in the world is only visible because they are reflecting light. In essence, everything we see, if it doesn't emit light, reflects light (Fig.04).
As in this example, the light-bulb will emit light in all directions and some of these rays will hit the teapot. The teapot will absorb part of the rays, in this case mostly the blues and greens, and bounce off the reds. Some of these bounced rays will pass through our pupils hitting our retinas, and this information will be sent to our brain so we can finally "see" the teapot.
The thing is, there are two ways this reflection may happen:
Diffuse reflection is a type of reflection where the light is reflected from the surface at multiple different angles (Fig.05).
Specular reflection is where the light comes in and reflects out from the surface at the same angle (Fig.06).
In reality both type of reflection will coexist on most objects, varying on intensity from one type of surface to another (Fig.07).
The shader will use the information contained in the Diffuse texture to define how the light that hits an object is partially absorbed by its surface and also diffusely reflected. And the Specular texture will define how the specular reflection will happen (Fig.08).
But, if both Diffuse and Specular are types of reflection that coexist on any surface, why aren't they only one, and why may they have different colors? As in this case where we've got a chess pawn with a brownish (wood) diffuse reflection and a white specular reflection (Fig.09).
At this point important information needs to be added to this equation. Physical/chemical characteristics of a material will affect how the light behaves when hitting its surface. Depending on the material's nature, the specular reflection may remain true to the original color of the light, or may be tinted by the color of the object (Fig.10).
So, in this example, the specular reflection on the toy and the chess piece maintains the original color of the light (white), while the specular reflection on the door knob or the Christmas tree ball is tinted by the objects' colors.
How so? For the purpose of our needs, we may reduce the materials to two basic different types: Dielectrics and Conductors. Dielectric materials do not conduct electricity. Conductors do. So, in a very non-scientific way that should only be used by artists and not someone writing a science paper, we could say that Conductors are all the metals or metallic looking surfaces, and Dielectrics are all the non-metallic surfaces, such as wood, plastic, rubber, clay, fabrics, etc (Fig.11).
And what is interesting for us to know is that Conductors alter the color of the specular reflection, tinting them. While the Dielectric materials will be neutral to the light and not affect the color of the specular reflection.
In the case of the Christmas tree ball, while it is made of plastic it still has a metallic look and that's because it was painted with a metallic finish. So it's made to look like metal. The same way if something made of metal is painted with a truly opaque paint, they will reflect as dielectric, and not as conductor, because the external layer that is reflecting the light is not of a conductive nature (Fig.12).
Please note: There is some very interesting information on the web showing how the electrons of conductor or dielectric surfaces are aligned in specific ways and how it affects the light that bounces on them. But for the solely artistic purpose of this study, knowing that it happens, and not all the details of how it happens, is enough.
So, if you want to create a material in 3D that truly recreates the physical aspects of an existing material, you have to understand its nature and how it affects the light.
Ok, we understood how real world materials behave, but how you replicate that in 3D?
In order to do that we must get one bit of technical information. It is very important for us to know that, during the rendering, diffuse and specular will be calculated on two separate moments. First the diffuse reflection will be calculated, then the specular reflection. Then, right after that, one is added to the other for the final result and the object is finally drawn on screen (Fig.13).
If you keep in mind that all specularity is simply added to the diffuse (as a simple mathematical addition) we start understanding how this part of the render works and we have a little more control over it.
Think about the colors in a shader as numbers that go from 0 to 1 in the RGB scale (yeah, not 0 to 255). So 0-0-0 would be black, 1-1-1 would be white, 0.5-0.5-0.5 a mid gray, 1-0-0 red, 0-1-0 green, 0-0-1 blue, and so on. If you know the values of your diffuse color, and you know the values of your specular color, you just need to add these three numbers individually to see the result of the specular reflection on top of the diffuse color. It will be through the good understanding of how this works that you will be able to represent the true nature of a material (dielectric or conductor).
If you need to create a Conductor material it is simple. You just need to use the same color of the diffuse as the starting point for your specular map. So, if you are making something made of gold, your diffuse and specular will be of some shade of yellow, if it's copper, some sort of brown/orange etc. This way the base color of the object (diffuse) and the highlights (specular) will be of similar hues. Of course you may change the intensity and even vary the hue a bit to achieve the specific look you are trying to get. But you will probably want to stay close to the original diffuse hue range (Fig.14).
But in the case of a Dielectric material, the light that is reflected as specularity is not affected by the diffuse color of the material. It maintains its neutrality. If the light is white, the reflection will be white, if the light is blue, the reflection will be blue etc. So, in this case, it would be reasonable to assume that the specular map for dielectric materials should have no colors at all, right? It should be grayscale... correct?
Well, not really. In order to get a good non-metallic result (neutral specular color), we need to neutralize the specular reflection using the inverse color of the diffuse (Fig.15).
Why? Because in RGB, whites and grays contain all colors. Since they have all colors, they will also contain the diffuse color, and once you add this portion of the diffuse color, contained in the grays of the specular, on top of the original diffuse, the result will give the material a metallic aspect. As you can see here (Fig.16).
If you add a green specular on top of a green diffuse, the specular reflection will be a bright saturated green, which is a very metallic characteristic. If you add a gray specular on top of a green diffuse, the specular highlight will still be tinted green, not as much as before, but still making a metallic, conductor, aspect. But, if you add a specular color that neutralizes the diffuse color, such as this magenta, the end result is neutral, in this case, white. That means that the color of the light will not be affected when reflected as specular highlights, giving you the impression of a dielectric material. Compare Fig.17. See how it completely changes the nature of the materials?
Alright, so now we know how different types of materials affect light in specific ways. And we also know that, in 3D, the specular highlight is the result of the specular color being added to the diffuse color... But how can one benefit from this?
The great thing about it is that once you understand this you have a solid starting point, instead of just guessing what color you should use. And that saves a lot of time!
So, as a general rule for creating your specular maps the first step is to use your diffuse texture as a guide, and separate the areas that should be metallic looking and the ones that should be dielectrics.
With the dielectric selection, create a Hue and Saturation adjustment layer and simply slide the hue slider all the way to the end. This will shift the hue to the inverse hue value, the one that neutralizes the diffuse color under the specular reflection (Fig.18).
You will still need to adjust all the other values, such as brightness, contrast, levels, any specific detail you may need. And, of course, you may want to change the hues to achieve a specific aspect that you are looking for, but in terms of first step for the colors, this is a pretty good start.
But what if, besides all this, you could also get a preview of how the specular reflection will look like when rendered, directly in Photoshop, or any other software with layers and blending modes? That can save some time as well.
The cool thing is that, you can!
As mentioned before, in order to see the result of the specular reflection on top of the diffuse reflection you just need to add their values. You can do that in Photoshop using the Linear Dodge blending mode. This mode simply adds the values of the current layer and what's underneath it. So, if you paste your diffuse texture on top of all layers of your specular texture, and set it to Linear Dodge, you will see the color of the final specular render under a white light.
Look at the following example (Fig.19). This is the diffuse texture.
And here is the specular map (Fig.20).
Notice that the ones on the left are respecting the true nature of the materials, with the wood (dielectric) using the inverse color of the diffuse, and the metal (conductor) with same colors of the diffuse. It has some scratches and a little more contrast, but it's still very similar to the diffuse in terms of hue.
The ones on the right are not good, they are just wrong. Wood specular matching the wood diffuse, metal specular with inverse color.
Now, if you put them on layers like in Fig.21, with the diffuse on top of all the layers of the specular file, and set to Linear Dodge, then the result you get is this (Fig.22).
This result will never look very good because it's like having the specular reflection on top of everything, as if there were several different light sources illuminating the surface from all possible angles. But you can already feel that the reflections on the left look more natural than the ones on the right.
Now, let's make this a little more interesting. What about having a preview like this one here, in Photoshop (Fig.23)?
To do that is actually quite simple. Below the diffuse layer, in Photoshop, create a group and make it Multiply. In this group add two new layers. The bottom one you will fill with black. On the top one you will create some white spots, faking the shape of the specular reflection that you would expect to see on the surface (Fig.24).
Now, you just need to drag the spots around to see how the specular reflection works for this material (see Fig.23).
Pretty cool, right? Of course, I don't keep these layers visible all the time while working on the specular texture. Sometimes I just don't use them at all. But every time I want to be sure I'm heading in the right direction I'll toggle them on and off, and move the small white spot around, to see if I'm still on track.
You may be curious about skin reflection. After all, a good skin reflection will be hued as a dielectric material (inverse of the diffuse color), but our skin does conduct electricity. Yeah, this is true. But our skin is a far more complex material, with several different layers and elements - epidermis, fat, oils, muscle, tinny hairs, sweat, salt, etc. Maybe the mix of these different elements results in a dielectric look, or maybe because oils are not conductive of electricity, and they are on top of all layers of the skin, the final appearance is dielectric... I don't know really (hey, I said this is not a science study!) But it's true, if you are trying to make a specular map for skin, you should start with the inverse hue of the diffuse.
That's it - I hope you found this tutorial useful! There are some other things you could do in order to make this preview of the specular reflection even more interesting, but I'll leave it for a next tutorial.