Continuing my series on 3D surfaces:
In this installment, I’m going to talk about how the color settings and texture maps on the surface as well as colors in the lights affect the results.
Mapping Things Out
First, let’s talk a bit about how texture maps work. If you’ve been in the 3D world for long, you’ve probably heard the term “UV Mapping”. FYI, the “UV” isn’t about sunscreen. 🙂 It doesn’t stand for “ultraviolet” it refers to the coordinates “u” and “v” which are used to look up information from a texture map.
u and v are used as coordinates that map (or translate) from the 3 dimensional object space to a 2 dimensional space on the texture graphic. Let me see if I can make this make some sense visually. In the following diagram, the point on the front face of the cube is mapped to the (u,v) coordinates of (100,75). Those coordinates represent the portion of the texture map indicated by the arrows at (100,75).

Mapping from a point on the cube to a location on the texture.
Now, you might wonder why we need special coordinates for this. As 3D artists, we mostly work in the standard (x,y,z) coordinate space. Well, consider if the cube rotates as in the diagram below. In this case, the (x,y,z) coordinates of that point on the cube have changed. However, the (u,v) coordinates remain constant.

Showing that rotating the cube doesn’t change the (u,v) coordinates.
If you get deeply into 3D graphics (especially if you start trying to write your own shaders) you will discover that there is a plethora of coordinate spaces, each of which serves a purpose.
X Marks the Spot?
So, now that we have a very basic understanding of what a map is and how it is referenced, how are texture maps used in shaders? Well … using my favorite answer for such questions … it depends! 🙂 Remember that the real answer is that how things like texture maps are used depends entirely on how the shader that is applied to the surface uses them. However, that would be a cop out on my part; so let me talk about the most common ways that you’ll see texture maps used.
It’s a Gray Kind of Day
In many of the cases I’m about to talk about, I’ll discuss whether the setting uses a color or grayscale image. Rather than repeating how a grayscale image looks, I thought I’d do it once to begin with.
Grayscale images are images where the color has been removed and only the value remains. The simplest way to think of a grayscale image is that the red, green and blue values of the color are averaged to arrive at a gray value. If a particular setting in a shader is expecting a grayscale image and you provide it with a colored one instead, it will average those values for you. This can create some interesting results. Consider the following diagram…

Different colors can have the same gray scale value
Although the three colors are quite different, the average RGB value is 127. So in a grayscale image, they would all look the same. For this reason, I often suggest that if a 3D artist is going to add a grayscale map to their surface settings, they should take the time to use the image editor of their choice to remove the color and make sure it is providing the values that they really want to see.
Adding Details
In my Displaced Bumps and Is This Normal? tutorials, I talked about various methods that we can add fine 3D details to our surfaces using bump, displacement, and normal mapping. In those cases, texture maps are used to indicate the magnitude of the changes to the surface. For bump and displacement, the map is treated as grayscale. Normal maps are a special case where they use colored maps, but the colors mean something. Dropping a texture graphic intended for the diffuse channel into a normal map will NOT give you the results you might have been hoping for. See my discussion of DAZ Studio Displacement in Carrara 8 for more information about normal maps.
Hiding Surfaces
In many cases, we can also apply a grayscale texture map to the opacity channel. Rather than saying that an object is 100 percent visible, or 50 percent visible, etc. We can use a texture map to change the opacity for specific parts of a surface. This is sometimes called transparency mapping. We see this most often in 3D hair content, but it can also be used in clothing materials to hide portions of a surface, for example to create a lacelike effect on a dress.
Strength Control
Most shaders will allow us to use a grayscale map in the strength channel. This allows us to have much finer level of control over the level of effect that a particular channel has on our surface. Basically, rather than telling the shader “Add 90% of the specular light to the surface”, adding a map says “Lookup the (u,v) location in the texture map and scale the level of effect by what you find there”.
It is important to note that when we’re using a texture map in the strength channel, the percentage value does still have a role to play. If we’re using a texture map for specular strength, and the strength is set to 100%, then the grayscale image will change the effective level from 0% for black (0,0,0) to 100% for white (255,255,255). If we change the percentage to 75%, then the maximum value for a white portion of our grayscale map becomes 75%.
Rose Tinted Glasses
So, those are the “other” purposes for texture maps, but this section of the tutorial is about colors, right? By far the most common purpose for texture maps is to use them in the diffuse channel to add color details to the surfaces. Without a texture map, we would be limited in what we could do for the color of the surface by what RGB values we could assign to it. Texture maps are what allow us to have human skin that isn’t uniformly a single color.
In this case, the texture map is telling the shader, “When deciding what color to make this surface, look up the (u,v) point in the texture map and choose the color from there.”
However, just like the strength channel discussion, the color setting you use in your shader values also comes into play. To understand how, we need to look at how rendering engines actually think about color.
For artists, we tend to think of colors in terms of Red, Green and Blue values. We’re probably used to expressing those values in terms of 0 to 256 for each color. However, the rendering engine doesn’t see them that way. To the engine, colors are RGB values where each value ranges from 0 to 1. So, while we might define Cyan as (0,255,255), the rendering engine sees that color as (0,1,1).
So what does that mean for how the color setting and texture map interact? Well, basically, the rendering engine multiplies the two together on a channel by channel basis. So, if you have the color value set to white (255,255,255), and the texture map lookup returns cyan (0,255,255), the multiplication is pretty simple…
Red = 255 * 0 = 1 * 0 = 0
Green = 255 * 255 = 1 * 1 = 1
Blue = 255 * 255 = 1 * 1 = 1
So, you’ll get a cyan color for that part of the surface.
However, consider if you’ve set the color value to magenta (255,0,255). At the same point, the texture map lookup returns cyan (0,255,255), but the math is going to look very different…
Red = 255 * 0 = 1 * 0 = 0
Green = 0 * 255 = 0 * 1 = 0
Blue = 255 * 255 = 1 * 1 = 1
So now your surface at that location is going to look pure blue!
By the Pale Moon Light
Let’s extend that color multiplication discussion in to lights. Do you know why a car looks blue? It is because the surface of that car is absorbing all of the light except for blue. Blue light is reflecting from the car and so that is what you see. The red and green portions of the spectrum are absorbed by the surface.
In most cases, we use lights that are white (or a close variation thereof) and so the effect that the light has on the surface isn’t that much of a factor. However, when we try to get fancier with our lights or we try to use them to create some sort of special effect by coloring them, we can end up with unintended consequences!
Let’s say that the surface calculations tell the rendering engine that the color of the surface is cyan (0,1,1). What that really means is that the surface will reflect 100% of the green and blue light that hits the surface. If our only light source is set to red (1,0,0), what do we get?
Red = 1 * 0 = 0
Green = 0 * 1 = 0
Blue = 0 * 1 = 0
We get black (0,0,0). Granted, most of the time our light and surface colors aren’t that neat and simple, but it does show why when you get too far outside the normal range of “white” lights, you can have unintended consequences.
1000 Points of Light
What if there are multiple lights in the scene? Well, the input from the lights are mixed together to get a final color for the surface. So, if we keep with our cyan (0,1,1) surface, and we have one yellow (1,1,0) and one magenta (1,0,1) light which happen due to planning or circumstance to be lighting the surface exactly equally, then we’ll get a surface color like this…
Light 1 (1,1,0)
Red = 1 * 0 = 0
Green = 1 * 1 = 1
Blue = 0 * 1 = 0
Color 1 = (0,1,0)
Light 2 (1,0,1)
Red = 1 * 0 = 0
Green = 0 * 1 = 0
Blue = 1 * 1 = 1
Color 2 = (0,0,1)
Final Color
Red = 0 + 0 = 0
Green = 1 + 0 = 1
Blue = 0 + 1 = 1
Final Color = (0,1,1)
So, we’ll end up with the cyan color of the surface.
Wrapping Up
For strength type channels (bump, displacement, opacity, color strengths, etc.) applying a grayscale image to the strength channel allows us to vary the effect of that part of the shader across the surface. Applying texture maps to color settings will force the rendering engine to lookup a value from the texture map when determining the color of the surface at that point. And if we use anything other than white in our color settings on the surface and lights, we have to keep in mind that we’re multiplying colors together, which can mean that we’ll end up with changes to the visual effect of the surface. This can work to our advantage, however, if we plan for it.
In my final installment in this series, I’m going to fire up DAZ Studio with a pretty simple scene so that we can see how varying one value while keep the rest constant changes the look of the objects. Maybe some visual examples will help where reading the text of this series wasn’t clear enough.