Nolimits 2 (materials part 1): The specular model

I’ve been guilty of doing this myself, but your method for creating materials in NL2 may well be to create a new material, add the diffuse and normal maps, take a step back and look in wonder at your lovely new texture:

A default normal-mapped texture

If that sums up your method, I’ll silently weep for you when I see your creations. But don’t worry, I suspect most of the people who are using bump mapped textures are doing this now. So, specularity might seem like an unusual place to begin for a series of material tutorials, but it is, in my opinion, the most important setting in getting a realistic appearance with your material.

NL2 Shading Modes

There are 3 main shading types in NL2:

3 shading modes

Options such as Wave or Vertex lighting are essentially “manual” lighting control. Bump lighting is for the purposes of this tutorial identical to regular lighting, bump mapping will be explored in a future tutorial.

Explaining Phong Shading

Taking a look at the specular highlight “dot”, especially on abstract objects like the untextured sphere above, it doesn’t make a lot of sense, or at least, it doesn’t look like any real object. I’ll show some examples in the following section, but now I’ll take a look at what it’s simulating in terms of light waves.

Not all objects look “reflective”, i.e. the mirror finish we refer to when we use this term, but obviously, all objects reflect light, as light is reflected off the object and into your eye, allowing you to see it. This type of light reflection is called “diffuse reflection”, light rays hit the object and disperse more-or-less equally in all directions. this type of reflection is responsible for most of the sphere as we see it above.

When a surface is smooth enough, reflection occurs without scattering, and light is focused directly from the angle of incidence to the angle of reflection, allowing you to see a reflection.

reflection of light on a surface

Every surface has both diffuse and specular reflection to some degree, specular reflection just usually occurs at a very specific angle of incoming light. At most angles we see a surfaces diffuse reflection, but at a specific angle, Light is reflected far more, causing the white dot.

Phong shading includes an approximation of this effect, it is performed on every pixel on the surface, and at certain angles will cause the specular dot. Its formula for the specularity, if you are interested, is where Theta is the angle of light hitting the object, and n is the “shininess value you’ve probably seen in the NL2MAT editor. Take a look at the graph for that formula:

sin of angle, power of shininess

Just imagine the height of the line to be the brightness of the specular dot, and you start to see how the formula forms the shape of the dot. full white in the centre and the curved edges cause the light to smoothly drop off around it.


So, we know the “shininess” value in the NL2mat editor affects the size of that odd-looking white dot, we’ll take a look at various values for that now:
spheres of various shininess'

Despite allowing you to choose a shininess between 0 and 128, there aren’t any times you’d want to go below 4 or so, and interestingly enough there are times when you’d want to go higher than 128, but the allowed range is fine for most real objects. A high value would be reminiscent of a Malteser chocolate, and a low value might be reminiscent of a ball made of velvet. The reason for the slightly tortured comparison there is that low shininess materials often need to be combined with a lower specular colour, as they reflect less specular light in general.

Back to our texture

If you’d like to try this yourself, download the texture and mesh here

A default normal-mapped texture
Here’s our texture from before. The texture work isn’t too bad if you don’t mind me saying, but it looks noticeably wrong in some aspect. The highlights are completely blown out to white, (try find that in a photograph) which also exaggerates the detail in the bump map.

Think about our shininess values from before. The rock clearly isn’t polished like a Malteser, but also doesn’t have the odd ‘all-over’ reflection of velvet. I went with a value of 8 (changes are more sudden at the lower end, so this is quite different to 4). I also reduced the specular colour to 70-grey, as the rock wouldn’t have much of a specular reflection at all. The result looked like so:

adjusted version of our old texture
Specular highlighting is still there, but it’s so subtle you only notice it when told it’s there; looking at the areas which were blown out white before, they’re now just gently brightened. This is now pretty realistic. Bump mapping looks a little harsh in the shadow, we can either smooth the normal map, or we can

increase the ambient colour (best to do this in the env, not the NL2MAT, as that’s a global change).

As one final experiment, we’ll change the rock to look like it’s been out in the rain. It’s going to gain shininess now. I chose a value of 96, which would be suitable for a rock that had been quite thoroughly rained upon. I upped the specular colour slightly to 90-grey, but be careful not to go overboard with that, in most cases we never want the specular highlight to be blown out to full white. I also darkened the diffuse colour a little, which helps give it a damp look. This isn’t necessary if your entire scene is wet, but if you have a dry and a wet version of an object near to each other, it will make the transition more believable.

adjusted version of our old texture

As before, subtlety was kept a priority. Specularity hasn’t wildly increased, but the highlights are now tighter, and more localised to the cracks and crevices of the surface, rather than the flatter areas, which wouldn’t be covered in a film of liquid.

An in-Scene Case Study

an example scene

If I asked you to describe the wooden floor shown below, hopefully, a word along the line of “polished” or “shiny” would come up pretty soon. This clearly isn’t some antique oak plank with cracks showing, it’s a smoothly finished modern flooring. In the past, I have jumped to conclusions with wooden textures. Wood isn’t reflective, besides, the NL2 wooden supports aren’t shiny, why would I make my floor shiny? Think about your materials not only in terms of the physical material they represent, but think of the various forms and finishes this material takes, and which one of these your texture map best represents. I also mixed in a little cubemap reflection, as seen on the far right, more on that later.

(shininess:64, specular colour:default)

You may have noticed, by the way, that there are several specular highlights on the floor here. Each light casts its own highlight on the surface. I haven’t created a light fixture model for this scene, but they’re Omni lights placed directly between each beam, for reference.

an example scene
The plaster looks especially nice in motion. The broad specularity just looks like the light hitting the surface, but bumps in the surface still show noticeable highlights

(shininess:16, specular colour:50,50,50)

Concluding points

hopefully, that’s given you some things to consider when making your materials, and some new insight on how the shading model actually works. Some concluding hints to refer to when making your materials would be: