Specular maps are the part of the Second Life materials system which allow us to create “shiny” objects. They determine how rough or smooth the reflections on a surface appear. In the photo above, the red ball has a high speculartity, with a small, focused specular reflection; the green ball has a low specularity, the surface appears to be a more matte, or satin like finish.
Creating the balls above was easy: I just applied a blank texture to the specular texture slot and adjusted the glossiness parameter. However, as you try to get more complicated looking effects using specular maps, you are likely to run into some complications that have given Second Life’s materials system a bad rap. I think the confusion stems from important settings being hidden away. Today we will take a look at these “secret” parts of the materials system.
Let’s start with some simple white tiles and add some realism using specularity:
Using these diffuse and normal textures we can apply the simplest specular map, which is the blank white texture. We’ll set Glossiness to 160, for sharp, but not blinding specular highlights.
With the blank white texture applied you can adjust the “tightness” of the specular reflection with the glossiness parameter. A setting of 160 looks like this:
The tiles look pretty good, but maybe a little too perfect. If we want to add some variation, let’s say some dirt and grime, we’ll have to use a specular map. I can create a simple specular map by multiplying some grunge over the diffuse tiles texture.
If we apply this as the specular map we’ll get some nice variation within the specular reflections so that these tiles don’t look brand new.
Unfortunately, this is also where we begin to run into some problems. The tiles only look good in this particular lighting setup. To illustrate, first I’ll delete the prim lights I’ve created, and then change the viewer to mid-day. Now the tiles look like this:
It is as though there isn’t any shininess to them at all. This is because, unless you happen to catch a reflection of the sun on the tiles, glossiness doesn’t reflect the environment within second life, it only reflects point lights as specular highlights. Naturally, the next thing you would think to do is up the environment parameter.
Now, not only are the tiles back to looking brand new, they also appear to be some sort of metal. So what exactly is going on here?
Specular Map? - Nay, Specular Maps!
The truth is, the Second Life materials system accommodates 3 different specular maps. If you read my tutorial on lighting, you’ll remember we used the alpha channel of a diffuse texture as an emissive mask. Have you ever wondered what the alpha channels of the normal and specular textures do? They are the two other specular maps.
The Specular texture tab has two settings, glossiness and environment. Glossiness controls specular highlights, and environment controls environmental reflections. The alpha channel of the normal map adjusts the glossiness. The alpha channel of the specular map adjusts the environment.
Notice that the parameters run from 0 to 255. Similarly, when you’re painting the alpha channel of a texture, your gray value can be any shade of gray from 0 (black) to 255 (white). This is not a coincidence. By using the alpha map, it’s as if you have a glossiness parameter to adjust for each and every pixel.
In the above photo, the prims on the right have a blank specular texture, with glossiness adjusted using the glossiness parameter. The prim on the left also has a blank specular texture, with the glossiness set to 255, but it also has a blank normal map, with an alpha channel, that controls the glossiness on a per-pixel basis.
Similarly, you can use the alpha channel of the specular texture to control the environmental reflection.
The specular texture that most people are using when they apply a specular map in Second Life is actually the specular COLOR map! In most cases, the specular color should just be a blank color. The rule of thumb is that materials that don’t conduct electricity (wood, plastic, etc...) don’t tint reflections. If white light shines on them, white light should reflect off of them. Materials that conduct electricity do tint reflections. If you shine a white light on a gold bar, the reflected light will be golden in color. (Semiconductors should never be rendered, cuz, who knows?)
Using The Alphas
So now let’s take the specular map that we made earlier for the tiles, and paste it into the alpha channel of our normal texture. We’ll set the specular texture to blank white, and set glossiness to 160 again. And we get this:
And there is an added benefit to just using an alpha channel, rather than creating a specular color map. It is less costly to render. In the first example we were using a normal texture and a specular texture. Each had 3 channels: red, green, and blue. Let’s say we are using 1024x1024 textures to make the math easier, in which case, each channel takes up 1 megabyte, so all together we used 6MB of memory on our graphics card.
The above instance uses only the normal texture, with four channels: red, green, blue, and alpha. So we are using only 4MB of graphics memory. You’re also using a little bit less bandwidth, so the textures should load faster as well.
Specular Alpha Channel
In many cases we could be done. You could apply the diffuse and normal textures to your floor, put in the default blank specular texture, setup your scene lighting, and it will look great. If, however, you want there to be some environmental reflections we will have to set up our specular alpha too.
For the specular alpha, I find things look better with a slightly darker, and higher contrast map. So I adjusted the levels and contrast until I had the grunge looking like this:
Then, I made a white specular texture, and pasted this into the alpha channel. I set both glossiness and environment to 160, and now the tiles work even outdoors with environmental reflections applied.
Specular maps are more complicated than they appear at first glance. There are 2 more maps than you first realize, but you need to know how to use them if you want your builds to look more realistic. If you would like a closer look at the examples, you can grab all of the textures and the demo build here.
Please share this post: