With the new lighting engine introduced in patch 81.8193.15, the core shaders of NWN:EE now accepts a number of inputs for generating more advanced content that benefits from the new PBR lighting engine. These can be set by supplying a custom material file that a given model can then refer to, using either the standard "bitmap" field or the designated "materialname" field, as described in the material file format section.
These inputs are used to modulate how meshes applied the material are rendered, generally by informing the renderer with the desired physical properties of the surface of the objects, which the engine will then use to generate results with a high level of realism.
The main way of supplying these inputs is by special texture maps. You specify these by adding a "texture*" entry in the material file, where "*" is replaced with the index in the table below, followed by your texture name for that input. If using NWN Crunch (recommended), you can also get the tool to generate the material file for you by simply adding certain standardized suffixes to the texture map names instead.
Below is an overview of the texture map inputs supported by default.
|0||3 or 4|
Base color / diffuse map with optional alpha.
This map affects the color of the diffuse reflection from the material. For metals, it also adjusts the specular reflection color.
If omitted, the material will simply use the texture matching the material name.
If you have a texture named Albedo, this will be your Base color.
Notice: PLT textures can not be designated through material files, so for those, the texture0 entry must be omitted (and the material file must match the name of the PLT texture).
Used to generate the illusion of higher levels of geometric complexity of models when doing lighting. For a basic introduction, see this.
You can supply three channel normal maps (RGB), but only two color channels (red and green) will be used, where green is up (the OpenGL standard).
Sets the material specularity. As the value goes toward 1 (white), this will also result in the material behaving as metallic, where the diffuse texture will be used for tinting the specular reflection color. For the same reason, a metallicness map can usually work as input for this texture (NWN Crunch also takes metallicness maps as inputs).
If omitted, the renderer will try to approximate a value based on diffuse texture alpha if environment mapped, and use a basic value that fits the average non-metal materials otherwise.
If omitted, the renderer will try to approximate values based on specularity (see above).
Used for parallax displacement as well as basic light occlusion.
By default, 1 (pure white) is the base level, with lower values resulting in the appearance of depressions in the surface geometry.
If omitted, light occlusion is partly derived from diffuse texture brightness.
Makes the material light up in the color and pattern
The example textures combined produce this result:
Example material file:
Other Texture Types
NWN only supports the six material types listed above, however texture sets can come with other types not listed. Although they can't be added as separate files, two material types can still be used by integrating them into your base texture: Ambient Occlusion; and Opacity. If you have both, the steps for Opacity should be done first.
Ambient Occlusion, sometimes called AO for short, is (in other engines) a map that a PBR engine combines with the albedo at render time to define how it reacts to light. It's the shadows. The NWN engine uses a diffuse map instead of an albedo but we can still bake an AO map in if it's provided. This texture is the simplest of the two to integrate into the base.
Presuming it is the same size as your base texture, copy and paste it as a new layer above the base layer then change the Mode from normal to multiply. Then export the base material as you normally would.
Opacity maps allow and to make parts of your material transparent.
Adding the Opacity map is a little trickier and I only know how to add it using the image editor Gimp.
First, open the Opacity map file and see what it looks like. If it's all white, don't bother to add it. Whitemeans the material is completely opaque. Check if the base file has an alpha channel. Remove it if it does. You will be done and you don't need the extra work below.
If it's all white, you should just add an alpha channel to the base image if it doesn't already have one and leave it. You will be done.
Otherwise, on the base color right click on the icon of the layer and choose Add Alpha Channel if it doesn't already have one.
Click on the Colors menu→ Components→ Decompose. Choose RGBA to include the alpha channel.
This will open a new instance of the image where RGB and A are split into separate channels. The Alpha channel will most likely by all white. You can see this by hiding the other channels with the eyeball icon. Either way, select this channel.
Assuming you've already opened the Opacity file in Gimp, and that's its the same size as the base image, copy the Opacity image and paste it into the Alpha channel.
Click on the Colors menu again and choose Components→ Compose this time (the Decompose option won't work). This will give you a new base and you should see transparencies on the new base texture. You would export this new file.
Add the Ambient Occlusion, if necessary, then export the new base material.
In addition, the standard shaders accept a number of standard parametric inputs, listed below.
For these to work, you must specify a shader to use in the material file, even if using the default. Usually you will want to just use the standard "vslit_nm" and "fslit_nm".
|float||Roughness||0.001 - 1.0||Sets the roughness for the material.|
|float||Specularity||0.001 - 1.0||Sets the specularity for the material.|
|float||Metallicness||0.001 - 1.0||Sets the metallicness for the material, which again determines the saturation of the specular reflection color. Normally, this is derived from specularity, but this parameter can be used to override that setting.|
|float||DisplacementOffset||0.0 - 1.0||Sets an offset to the base level for displacement when reading the height map. By default, 1.0 (white) is the base level, but with a DisplacementOffset of 1.0, the base level is 0.0, etc.|
This is an example material file (used in the core game to make ice appear non-metallic):
When defining custom uniforms in a shader, use this suggested notation.
- If the parameter is a variable used in a function, define the uniform in the shader beginning with a capital Letter, and omit the data type prefix. For example, instead of "fSunshine", use "Sunshine". This helps differentiate between uniforms and shader variables.
- If the parameter represents a switch, define the uniform in all-caps with underscores between words, like "SUN_POWER"
Tools for creating advanced texture maps
Free PBR/advanced texture map resources
- CC0 Textures
- Free PBR Materials