Page tree
Skip to end of metadata
Go to start of metadata

In patch 81.8193.15, a new lighting engine was introduced into Neverwinter Nights. Essentially, this adopts what is commonly referred to as physically based rendering (PBR for short). The basic principle is to use the laws and insights from physics when designing the algorithms used to render the game (rather than just relying on aesthetics and subjective estimates). This has the obvious advantage of achieving a high level of realism, but further, it can also make it easier to achieve convincing results as a content artist too: by simply supplying the renderer with some basic information about the properties of a surface material, the renderer will take care of making it appear as so. For example, if you want something to look like metal, all you have to do is just to "tell" the renderer that it's metal. Practically, the main way you do this is by using special texture maps.

The changes in the new lighting engine are numerous, but when designing content for it, the most important new feature to be aware of is the introduction of specular reflection. Understanding what this entails and how it works is essential for working with PBR content. The sections on linear color space and per fragment lighting are mostly background information.

Specular reflection

How an object is illuminated is generally determined by how the light it receives is reflected from it. For example, if an object subjected to white light appears to us as blue, it means that all incoming light except the blue is absorbed by the object, while the blue light is reflected to us as the viewer.

But there are in reality two (main) ways in which this light reflection occurs - as diffuse reflection and as specular

Diffuse reflection is the only one that existed in the old NWN lighting model, and it is the most simple to calculate: whatever light that an object receives, enters the upper layer of the surface material, where some is absorbed and the rest is reflected back in a uniform way, diffusing the light in all directions. The result is that the surface appears to us as having the same color when observed from all viewpoints. The involved equation can be put as simple as incoming light × material color = color it appears on screen.

Specular reflection, on the other hand, occurs at the very edge of the surface and is more complex to calculate. The amount of light reflected specularly in our direction as viewers changes significantly depending on the light incidence angle and our viewpoint, as well as the minute variations in the surface geometry.

We are most familiar with specular reflection when it appears in a mirror, where what you see on the mirroring surface changes as you adjust your viewpoint (like taking a step to the left or right). In that way, specular reflection always follows what is often called the “law of reflection” that dictates that the angle of reflection is the mirrored incidence angle.

The very same specular reflection that happens on the surface of the mirror is how light is reflected from all metal surfaces, making them appear “shiny”. But in reality, this specular type of reflection actually takes place to some degree whenever light hits any material. To some extent, everything is a mirror.

How and how much light is reflected in this way varies a great deal though. When calculating specular reflection from a given surface, two main properties are used to determine the final appearance: the surface roughness and the material specularity factor (aka. specular reflectivity).


Specularity signifies just how much of the incoming light is reflected immediately on the surface as specular reflection, with the remainder passing into the material (to then potentially be reflected by diffusion or absorbed entirely). For metals, the specularity factor is generally high (50%+) whereas for non-metals, it’s often only about 4-5% of incoming light that is reflected specularly.

When designing your content, there are plenty of resources online that provides list of specularity values of common materials, e.g. some values taken from here:

MaterialSpecularity value

If you cannot find the value you are looking for, you may be able to find the index of refraction for the material (IOR). Using this, the specularity value for non-metals can be calculated as (IOR-1)/ (IOR+1) squared. Or you can just use the general rule of thumb of having about 0.02 for liquids, 0.04 for solids, except metals, which instead should have values close to 1.0.

Note that in NWN:EE, metals should always be given a value between 0.9 and 1.0, depending on purity (with 1.0 for pure metal and lower if the material is mixed or the surface dirty). This is because metals have varying specularity between the various color elements of the incoming light, resulting in a colorised reflection. The concrete specular reflection color will then be derived from the base color texture.

You may wonder why specularity matters for non-metals given that the values are generally very low, but the tricky part here is that these values are actually only what applies when the light hits the surface head on (that is, the light incidence angle being perpendicular to the surface plane). The effective level of specularity scales with the incidence angle so that the lower the angle is, the higher the ratio of specular reflection – to the point that it becomes almost exclusively specular reflection for all materials as the incoming light angle moves toward zero (being parallel). This is why the surface of water appears almost like a perfect mirror when it is reflecting the horizon, while when you are looking straight down at your own reflection, it looks much fainter. This is often referred to as the Fresnel effect.


But if all materials reflect light almost entirely as specular at steep angles, why do they not all reflect the horizon like a mirror? This is where surface roughness plays in. Roughness represents how uneven the surface texture is on a minuscule level and determines how much the reflected light is dispersed. When you have no roughness, i.e. a completely smooth surface like still water, the surface reflects sharply as a mirror and there is no dispersion. But as the surface gets gradually more rugged, the reflected light becomes more scattered, making reflections appear blurred. This is indeed what gives some metal surfaces a matte look.

Consequently, even though all materials do reflect light almost exclusively as specular when viewed from steep angles, surface roughness will often make the reflected light disperse so evenly that it resembles regular diffuse reflection.

Determining the desired roughness value for your content is more of a subjective estimate, but generally, highly polished surfaces will have about 0.05-0.1 and very rough surfaces like natural rocks, bricks and similar will be about 0.6-0.7.

Specular reflection color

Even if rough surfaces disperses the specular reflection in a way that is very similar to diffuse reflection, specular reflection still has a notable impact even on the appearance of rugged surfaces, because it happens before the material absorption of light and is consequently unaffected by the normal material color (i.e. how the material absorbs different colors of light). For most non-metallic materials, this means that surfaces appear lighter and more desaturated when observed at steeper angles. This whitening effect is in fact most profound on rough surfaces because the dispersion additionally makes the specular light visible from more angles, and it is the same reason why e.g. an unprocessed rock appears less colorful than a polished one.

For metals (as noted above) it is a bit of a different matter –  here the specularity factor is often different between the various colors of the light, and given that metals in fact do not reflect light as diffuse reflection at all, this characteristic is indeed what makes metals appear as even having a color. E.g. for a metal such a gold, the relative specularity factor is higher for yellow light, giving it its golden hue.

Since NWN derives the specular reflection color from the base texture for metals, the base color texture should be set to the desired specular reflection color (in standard sRGB color space) of said material. Calculating these colors is a bit complex and beyond the scope of this entry, but it generally works to just set the values to whatever colour you want your material to have. Here are some common examples:

MaterialRedGreenBlueIntegers (0-255)Hex


250, 249, 2470xFAF9F7
Gold0.9620.8890.647245, 227, 1650xF5E3A5
Copper0.9440.8600.737241, 219, 1880xF1DBBC
Iron0.7470.7380.729190, 188, 1860xBEBCBA


A demonstration module, useful for viewing the results of various roughness and specularity values can be downloaded here:

Useful resources

Specularity and refraction indexes

Linear color space and gamma correction


Per fragment lighting


  • No labels