Part 23: Intro to Unity's Specular Workflow

Last time we learned how to make a skybox. Today we're going to learn about the Specular workflow in Unity. We won't be talking about how to actually create a specular highlight -- if you're looking for that, you can read about adding a simple specular highlight here and a somewhat more complicated one here.

Physically Based Lighting

In the toon shading we've done in the past, we didn't really care about anything except light direction and bumpiness, but to get shading that really pops, we want to think about how rough/shiny an object is for the entire object's color, not just on the highlight. It really lends some zazz, even if you're still using toon shading otherwise. Shaders that do this are often said by shader nerds to use "physically-based lighting."

(and in fact today's lesson is prep for being able to tackle making the shader pictured above!)

In my experience, unless you are trying to do something differently on purpose, it's a good idea to reuse as much of Unity's built-in shader functions as possible rather than writing your own functions that just do the same thing. Unity has two main workflows for physically based lighting: metallic and specular. The metallic workflow is the default, so if you've used Unity before or have been following these tutorials you've seen it, but we haven't talked about the specular workflow yet.

Specular vs Metallic Workflow

Up until now we've been working with the model:

albedo - the color the 3d thing seems to look like without any highlights or shadows
metalness - the higher this is, the more the main texture color is mixed into the highlight color and the more black is mixed into the albedo color
smoothness - the higher this is, the more shiny and reflective the object surface is

But consider instead:

albedo - the color the 3d thing seems to look like without any highlights or shadows
glossiness - the higher this is the shinier the object seems
specular color - the color of light bounced off the object, and thus how reflective the object surface is

Wait wait wait, reflectiveness and shininess don't have to be the same thing? They do not! And highlights don't have to just exist on a color scale of texture color <=> white. 

You can put Unity's Standard Specular shader on a material by opening the shader dropdown on the material and starting to type "Specular" then clicking Standard (Specular setup) when you see it.

Check out this shootyman, who's got specular color maps instead of metallic maps. Left is using Unity's standard specular shader, right is using Unity's standard shader, both with the same smoothness value in the material.

Wow! Specular workflow looks great! Sign me up!

Well, let's have a look at the spec maps tho. It's a little more complicated than just throwing on the color of the highlight you want.

These maps are real small, 256 and 512px respectively. Zoom. Enhance!

Green? You're tellin me homeboy's skin's shininess color is green?  Well we just talked about metallic workflow, if the skin reflection color was the same as the actual skin color he'd start to look metallic!  Yeah turns out making a realistic imitation of how light scatters on semitranslucent objects (like skin) is equal parts art and science. (see: )

Dangit, I didn't come here to think real hard about things, I got into making video games because I'm bad at art AND science! It's OK tho, there's a trick you can do to get specular color maps that are reasonably good in no time flat!

Specmaps For People Who Don't Know How To Specmap

Open the diffuse map (the picture with the main colors) in your favorite image editor. I will be using CLIP studio, but you can use Photoshop, GIMP, krita, or any other program that lets you use layers. (GIMP and krita are free!)

Duplicate the layer and invert the colors of the top layer.

In a new layer on top of this, black out the parts that shouldn't be shiny at all. (Using a new layer rather than drawing black on top of the inverted layer directly lets you erase the blacked out parts if you make a mistake!) If there are parts of the original texture that already have the specular color you want, copy them from the bottom layer and paste them on top of everything else. (in this case, the hair and skull charm.)  

Also here I then increased the brightness and contrast of the hair.

Don't worry about making it perfect, I spent like 10 minutes or less on this. Et voila!

Right is Unity's Standard shader with smoothness at 0.5. Left is Unity's Standard Specular shader with smoothness at 0.5. That doesn't look bad at all!

That's a lot to digest, so I'll leave it at that for now. Next time we'll look at how to take advantage of Unity's built-in specular workflow functions to make a toon shader with full-color shininess!

In the meantime, I've attached the specmap I made for today's lesson to this post so you can play around with Unity's Standard Specular shader, and maybe get started making some specmaps for your own models. Let me know how it turns out!

Tier Benefits
Recent Posts