Specular lighting in Unity 5b is off the hook!

The Specular lighting possibilities in Unity 5b are off the hook! I am still discovering, but I thought I’d share some interesting research that is yielding some awesome results:
This is my understanding and research. Gaining this “perspective” has allowed me to create exactly the effect I’m looking for in the context of specular highlights.

My perspective is the map defines how each pixel responds to (reflects) specular light. The result is a combination of all the lights contributing to specular “limited” by the value in the map. Black reflects nothing, while white reflects 100%. So a 50% gray map will transmit (reflect) 50% of the specular light incident on the surface (from all contributing lights). Your view angle and the angle of the light incident of the surface obviously effects your final “view” of the surface.

In Photoshop, I found I can use the Levels Adjustment (for a given specular map) to discover and control basic specular properties:
Output Levels (high and low sliders):
set low to make darkest value in map lighter than black, yielding some specular for every pixel
set high to make the lightest value in the map darker than white, yielding less than pure specular for every pixel. This is a GREAT way to make the overall surface duller or limiting how “hot” the highlights are.
Input Levels (high and low sliders):
set low values greater than 0 to make surface duller
set high values less than 255 will make shinier

You can also adjust the mid-range to push all the values toward black or white while still observing the output levels you set.

Taking this approach allows me to add specular highlights very subtly, being able to dull down or gloss up a surface with a procedural approach. For instance, I can (too easily) get cement to look like it incorrectly has puddles of water everywhere (white areas in specular), or now I can set the input low to 16, giving some specular to every pixel and “clamp” the output high to 180 and the cement gets dull with no puddles. I am no longer afraid to “mess up” a specular map

If you’re just discovering something, you’re in no position to make a tutorial.

If you use white specular to make a puddle shiny, it won’t look like water, it will look like mercury. You should be varying the glossyness value mostly instead (that’s the alpha channel of the specular map). For the watery puddles try a specular value of about 4 to 8 percent, and glossyness (alpha) of pure white.

1 Like

Ok, no tutorial, but what I am just discovering is how different and how much better specular lighting is in Unity 5 compared to earlier versions. In my career I have made lots of tutorials; I just wanted to share this discovery in a meaningful way to other developers who may be digging into this. After reading my post, I thought some screenshots would illustrate my findings better. I found the Levels Adjustment very pedagogical where the new specular lighting is concerned.

To your note with the glossiness in the alpha channel of the specular map: that doesn’t seem to work for me in U5b I may be doing something wrong, but I found I must use the same image (PSD) for both diffuse and specular and Unity uses the top layer from layers (for diffuse) and the 1st alpha channel from channels (for specular). I want it to work the way the docs say, but it doesn’t seem to.

Correction: Zomby138 was correct; The PBS acts just the way the docs say; I was having noob trouble creating images with alpha channels consistently. A solution that worked for me was using the SuperPNG plugin in PhotoShop. Once I had that solved, I was able to reliably create specular/gloss maps.

For the specular input, it’s RGB for the Color/intensity of specularity/reflection, and the Alpha for the Smoothness (or Glossiness or whatever you want to call it).

1 Like

Thanks for the corrections Zomby138 and AcidArrow. Then I am
“doing it wrong”, but my results are still impressive. The way I’m doing it I must be getting the color map for the specular and the alpha channel as you say is the glossiness. So my research applies to (incorrectly) using the color map for specular and tweaking the glossiness with levels. I look forward to working with this new information:I have a whole new dimension (channel) to play with, which will obviously give me a much wider range of possibilities.

You have much to learn, Grashopper.

Unity is now using what is called Physically Based Shading/Rendering. Whereas the old way of doing things was purely focused on the appearance of a surface, this new thing (PBR) is focused on what defines a surface, and how the surface will look as a result. Particularly, PBR focuses on what the diffuse color is (how does the surface absorb and scatter light), the specular color (how does the surface reflect incoming light), and how rough the surface is (whether the surface is very rough, whether it’s polished smooth, or somewhere in-between).

EDIT: One important concept here: surfaces reflect light, and absorb/scatter light. If light is reflected from a surface, that same light cannot be absorbed and scattered. Therefore, the more light a surface reflects, the less it absorbs/scatters (the diffuse color will appear darker)

Now, it’s important to remember that there are two general workflows for this technique. One is called Specular Color, and in this workflow you author an Albedo map and a Specular Color map, and this is what Unity has gone with. The other is called Metalness, and instead of authoring a Specular Color map, you author what is called a “Metalness” map, and it defines how metallic a surface should appear.

When I say “metallic”, what I mean is that nearly all surfaces in your game can be roughly divided into two categories: non-metallic, and metallic. I’m going to ignore the Metalness workflow for now and describe the Specular Color workflow, just note that some of what I say doesn’t apply to Metalness (I’ve seen a lot of people mess this up), but you don’t have to worry about Metalness for now because Unity does not use that workflow.

Anyway. If you want to define a non-metallic surface, you want a low specular color. Generally, you can safely flood-fill a 4% grayscale value (6% if you’re working in sRGB). This might seem counter-intuitive, because it sounds like we’re making a surface that isn’t very shiny.
However, it turns out that in real life non-metallic surfaces do NOT reflect much light when viewed head-on. However, the amount of light they reflect increases towards the edges, increasing to maximum when viewed at glancing angles. This effect is called fresnel. Unity’s new Standard shader models this effect, as does any good PBR system.
So, if our specular color is low, then how do you define shiny surfaces? With roughness. You use the roughness map to define how rough or smooth a surface is - the smoother the surface, the shinier it looks, the rougher the surface, the duller it looks.

OK, so other than non-metallic surfaces, how would you define a metallic surface? Well, with a metallic surface, you would increase the specular color (generally, the specular color is the color of the metal).

I probably haven’t done nearly as good a job explaining things as I’d like, so here’s more info: Tutorials & Resources | Marmoset

1 Like

Thank you PhobicGunner, I do indeed have lots to learn. Thank you for your insights. I have read and understood the documentation on PBS, and I am just figuring out how to wield it.
I am an engineering physicist (by degree) and and studied optics and surface phenomena purely from an electromagnetic or Quantum Mechanical view, but I’ve always been an artist interested in 3D and how to simulate real world phenomena (light, surfaces, etc), so I am excited that Unity is going with PBS and the Standard Shader.
Prior to Unity 5, I was writing my own shaders, attempting to do PBS by own way. I am excited to drop my own bulky variations and just use the Standard shader.

I highly recommend Substance designer/painter to work with materials/textures.

Screenshots broken.

Thank you Roni92 ; I will check it out. I went back to the drawing board and studied the material on PBS and Unity Standard shader, I decided to try Modeling a real world example of a glossy hardwood floor. I am very pleased with the results.

Modeling a real world example of a glossy hardwood floor


Bright 300W halogen light shining at ~45 degree angle (holding it above my head with one hand and the camera in other) Notice the size and intensity of the highlight. Notice highlight on baseboard. Also at this angle, no (sharp) reflections visible, and the wall looks indistinct and moderately lit at that angle.

Same “scene” at different angle: Highlight on baseboard is slightly brighter and tighter. Good ol Fresnel in action! Reflections at this angle are clearly visible and sharp (approaching mirror). Notice how the reflections become less distinct as the angle (between your eye and the floor surface) increases (from the wall toward the camera). Also note the broad (fairly hot) highlight on the semi-gloss wall at this angle (absent from the previous view).

In Unity 5b11, In simple scene to test textures. On the floor, I have a wood floor texture I grabbed from asset store. I “modeled” the specular/glossiness using the Standard Shader’s color and slider combination by guessing reasonable values using what the PBS documentation described.

Specular Color of 85 and a smoothness of .9 I can see reflections from the ceiling, but the highlight is not “hot” enough".

It seems from practice, the specular “channel” is in complete control of the amount of light that is divided between specular and diffuse. Setting the specular at 100% dominates any diffuse. This slider is therefore a balancer in the conservation of light equation. It shifts the total light from completely diffuse to completely specular, and everything in between. I would like to have separate control over certain channels, like being able to blur the reflection independent of the RW properties.

Increasing the Specular to 105 achieves the highlight I’m looking for. The reflection does not model the real world, it’s too sharp, so… try decreasing the smoothness?


Decreasing the smoothness to .85 makes the floor less glossy: the light is scattered and the highlight is correspondingly larger. Notice reflection is largely unaffected. From simple testing, the desired reflection is found by varying the specular value at the upper range. Let’s revisit the Specular range the material is in (next post):

Continued from previous post.

Pulling the Specular value down into a more suitable range


At 68, the reflection is correct on the area of the floor lit by direct light (the diffuse “channel” is dominating). In shadow however, this amount of specular 68 or 27%
is surprisingly enough to dominate the diffuse and create a reflection. Let’s attempt to restore the highlight.


Increasing the Smoothness to .93 makes the highlight hotter at the expense of the size). This is where I wish we had more control (like a logarithmic slider that would give more sensitivity in the interesting ranges).
The reflection of the ceiling seems too distinct. Let’s check other views.


Putting camera close to floor and turning it to face wall, we correctly see very sharp reflection at this angle. Notice how the reflection appears less distinct in the areas lit by direct light.


Putting camera over area lit by direct light gives desirable results: reflection at glancing angles and dominated by diffuse in area lit by direct light. Also seen below

PBS is a fascinating subject, and the standard shader does a fantastic job of simulating RW materials as far as I can tell. It takes a bit of attention to create a usable material, but it’s well worth it. Instead of learning the “tricks” to make a material behave correctly, we can model materials after real world examples and expect to get usable results.

While I’m often wishing I could get different behavior (like being able to have a large highlight on a glossy surface, or a blurrier reflection, etc.), the result is a better rendering of a given PBS material under a wide variety of RW-like lighting conditions.

A quick note: I’ve worked with many different CG systems (spanning decades) and this PBS shader system is the most intuitive way to create materials I’ve ever seen. I used to spend a LOT of time tweaking properties and then testing them under different lighting conditions. It’s much faster and more intuitive to learn how materials really behave and create with this knowledge.

Another view yielding interesting and encouraging results:


View from under an object casting shadow. Notice the extra light in the specular highlights transmitted from the metals* in the scene (via the reflection probe at center of room). Also of note is the apparent inner-reflections (reflected reflections) seen at the bottom of the gold and chrome capsules.

*unrefined metallic textures using PBS educated guesses.

I’m not so sure about that as a rule. Sometimes the guy who can best teach someone who doesn’t understand a thing is the guy who freshly remembers what it’s like not to understand it.

An expert in this case might go deeply into what makes every texture map on optical physics and what makes PBR tick (much as Unity did in their first presentation on PBR), rather than “if you make this thing light it starts looking like metal”.

Sidenote, it’s amazing how pretty U5 can make primitives look.

I’d just like to point out, your wood floor should probably be around 4% specular (deviations from that should be very small). Most of your detail goes in the roughness map rather than specular.

1 Like

I appreciate the feedback and I agree with you, except I don’t get the appearance I’m looking for with specular set any lower than about 25% (the highlight disappears). I start out by selecting the specular “range” my material is in (using RW values). What is a wood floor? Physically it’s a combination of materials, each with different surface characteristics (transmission, absorption, reflection, etc). It is wood covered in layers of finish. Instead of attempting to model what is physically there, for specular I think I’m largely modeling the surface on top of the wood (the finish), because that plays a larger role in the appearance than does the wood in the context of specular. Am I wrong? I want to do this right. For unfinished wood, I would give that a 4% specular, but highly polished surfaces?

To help my understanding of the spec/smoothness stuff, I made a hi rez Specular/Smoothness map where the specular is a horizontal gradient from black to white and the roughness map is the same but vertical. I mapped this onto a huge plane (so specular varies along x, smoothness along z) and lit it with a directional light and gave myself a flashlight. Now I can move around to any point on the plane and I can see what that specular/smoothness combination does under different lighting conditions. So if I go to where the specular is 4% and I move along the Z, my specular value doesn’t change and I can see the surface as the smoothness vary from 0 to 100%. There is NO place along that line where I get a highlight (even if I put my face right up against the floor and blast light into it). I go back to spec=0 and smoothness=100% and start moving in x (increasing specular) until I can see the faintest perceptible highlight. Now I can move along z again and I see the highlight spread out get fainter. I can move in x and z and “tune” my highlight.

I’m a physics guy and love the PBS stuff, but if I can’t get the appearance I’m looking for with RW values, I gotta deviate. Like in simple physics problems we ignore wind resistance and it gives a reasonable approximation to the motion of a projectile. If I want to model the behavior with the wind, I have to deviate from the approximation. Maybe if I set up a layered material using transparent finish, I could give the wood a 4%, my finish a 25% and the combination would be better, but I’m usually looking for computationally “cheap” approximations that yield acceptable results.

All that means is I deviate from RW values if it looks better.

To your point, that’s exactly why I shared this. I am not new to computer graphics whatsoever, but I am fairly new to developing materials in Unity. As part of my physics requirements, I had to tutor students, and remembering what it was like to not understand was key for me to be able to teach effectively.

I used simple primitives to limit my research variables and to show that anyone can have this same setup in a few minutes.

Let me read you this part of the article on Marmoset’s website:

Non metals tend to have an incredibly narrow range of reflectance values, and almost always on the very low end of the scale. In fact, most materials you find in real life only deviate very slightly from the 4% value (which is why it works as a good hardcoded approximation when using Metalness maps). That includes the varnish on top of the wood. The only measurable difference in material property between the wood and the varnish on top of the wood is likely to be the roughness of the surface.

1 Like

The other thing to keep in mind is that, unless you manage to replicate the exact lighting conditions of the photograph and scan the exact material properties of the wood surface, you are very unlikely to replicate its exact appearance. You’re better off trying to make something that generally looks like wood rather than looks exactly like the wood in a particular photograph.

EDIT: And additionally, one of the biggest reasons for PBR, a mission statement if you will, is that you don’t spend a lot of time endlessly tweaking things until it “looks right”. You pick values which you know are close to real-life measurements and observations and it should just look good in whatever lighting environment you put it in.

1 Like