Difference between revisions of "Arcane University:NIF Data Format"

The Beyond Skyrim Wiki — Hosted by UESP
Jump to: navigation, search
m (Format)
m (Texture Slots: widen table)
 
(57 intermediate revisions by 9 users not shown)
Line 1: Line 1:
 +
{{trail|Implementation|Nif Implementation}}
 +
'''NIF''' stands for "'''NetImmerse Format'''," which is a file type that was created for the NetImmerse engine in 1997. This later morphed into the Gamebryo Engine (used for Morrowind, Oblivion, and Fallout 3), which in turn was the basis for the Creation Engine, used by games such as Skyrim, Fallout 4, and Fallout 76. Much more than simple 3D mesh files, Nifs can also contain complex shader and texturing information, as well as character rigs, animations, collison meshes, physics properties, and other information that is passed to the game engine. This article details the structure and workings of Nif files as they are used for Skyrim.
 +
 
== General NIF structure ==
 
== General NIF structure ==
 +
[[File:NifMeshstructure02.jpg|thumb|right|Use this option in NifSkope if the blocks are not shown in tree format.]]
 +
[[File:NifMeshstructure01.png|400px|thumb|right|An example nif block structure.]]
 +
Nifs are organized into blocks or nodes arranged in a hierarchy or "tree." Each block has various properties that define how it functions in the game.
  
'''NIF''' stands for "Net Immersive Gamebryo" file format. The technology was bought by Bethesda in the 90ies from Gamebryo, and modified since. They use BSShaderProperties and BSTextureSets to render meshes. NIF (Netimmerse Gamebryo) files in Skyrim are the files that hold the 3D Model information necessary to display objects in the game. When you open a NIF file in NifSkope, every NiTriShape represents a 3D Object instance. You can get Nifskope, a community made tool, for free at: http://www.niftools.org/. A single NIF file can have multiple instances of these and they can reside under various parent nodes. Make sure, that you visualize it as a tree diagram. Note that there is a hierarchical order, similar to shoulder -> arm -> hand -> finger. In theory, your mesh could be sorted differently, but most meshes look like this. If you see slight variations, don’t worry too much, the system behind is the same. The top-level is most commonly a BSFadeNode (static bodies) or a Ninode (Skinned rigged meshes) or a BSLeafAnim/tree node (plants). The BSX Flag below is for activating the collision. The bhkCollision object is the mesh of the collision. The first sublevel has the Nitrishape, which is the “body” of the mesh. There can be as many as you want. Each Nitrishape then has a second sublevel, which contains a NirtiShape Data tab and the LightingShaderProperty. This is where we set up the way the mesh is rendered. Here, we set the shader type and the shader flags and controllers. If you double click on the BSLightingshaderProperty, you find the third sublevel, the TextureSet, which contains your texture slots. Meshes can be rendered in Skyrim according to their '''BSLightingShaderProperty''' or the '''BSEffectProperty'''.  
+
The root node always has a block ID of 0. It is most commonly a BSFadeNode (static bodies), a NiNode (skinned rigged meshes like armors), or a BSLeafAnim/tree node (plants). The root node will usually have attached [[#Metadata|metadata]] blocks that activate other nif properties like animation, Havok physics, and inventory display. 3D Meshes are represented by [[#TriShapes|TriShapes]]. The surface material is defined by a [[#Shader types|shader property]] block, either a Lighting Shader or an Effect Shader. Animations are defined in Controller blocks, or in child nodes of the shader property.
  
 +
== TriShapes ==
 
A NiTriShape can have the following child properties among others:
 
A NiTriShape can have the following child properties among others:
* NiTriShapeData is the actual mesh.
+
* '''NiTriShapeData:''' the actual mesh data (vertices, normals, tangents, UV map).
* BSDismemberSkinInstance is the information necessary to handle limbs being dismembered from the base mesh. Those nodes hold all skinning/rigging data. They tell the mesh how to deform during animation
+
* '''[[#Shader Types|Shader Property]]''' (BSLightingShaderProperty or BSEffectShaderProperty): holds lighting and texture information.
* BSLightingShaderProperty holds lighting and texture information.
+
* '''[[#Transparency|NiAlphaProperty]]:''' tells the game how to handle transparency in the mesh, if any.
* NiAlphaProperty tells the game how to handle transparency in the mesh.
+
* '''BSDismemberSkinInstance:''' only present in skinned meshes like armor. It contains the vertex weighting to handle limbs being dismembered from the base mesh, and deform during animation.
Nifskope Gamebryo NIF branch hierarchy example (object window):
 
  
[[File:NifMeshstructure01.png]]
+
'''BSTriShapes''', used in Skyrim Special Edition, combine the NiTriShape and NiTriShapeData into a single block. They are not widely supported by nif import and export tools, and cannot be manipulated as easily within NifSkope. They can be converted back and forth by nif converter tools like Cathedral Assets Optimizer or SSE Nif Optimizer. However, LE nifs work fine in Special Edition, and do not need to be converted. In fact, SSE nifs use less precise values, so LE nifs are recommended regardless of which version of the game you are modding.
[[File:NifMeshstructure02.jpg]]
 
  
===Understanding BSShaderTextureSet textures and Skyrim===
+
'''BSLODTriShapes''' are the same as NiTriShapes, except that they fade out some distance away. This is used in LE to make small details on architecture nifs fade out ''before'' it is replaced with an LOD model. This block has no effect in SSE (no parts fade out individually).
Textures are the only way for you to paint your mesh and make it look the way you want which means that, apart from the mesh itself, the textures will be the single most important work. As the mesh is built using triangular faces, to know what to draw on each face, you create what is known as UV Maps in Blender or 3D Studio Max. The UV Map is where you take the 3D triangles of your mesh and map them on to a flat plane. This way the game can project a texture back on to the mesh based on the information in this UV Map. It is therefore important to understand that when vertices are moved, they will stretch and shrink the face and can cause the texture to look strange. This is more an issue with how 3D engines work and not anything you can control. Just keep in mind and work around it if needed.
 
  
'''The shader will apply light and effects based on 2 things:'''
+
==Texture Slots==
* The BSShaderTextureSet textures.
+
[[File:TextureSlots03.png|thumb|right|upright=2|NifSkope uses [[wikipedia:zero-based numbering|zero-based numbering]], so the first slot is Slot 0, the normal map slot is Slot 1, etc.]]
* Flags set for the BSLightingShaderProperty. Each flag only works with a specific set of textures.
+
All textures used by Skyrim are [[AU:DDS Data Format|DDS]] (Direct Draw Surface) files (with a few exceptions, such as menu art). These textures are typically referenced in the <code>BSShaderTextureSet</code> block, as shown at right.
  
=== Overview of the Texture Set Slots ===
+
Some slots are reused for multiple different purposes. For example, when a mesh uses the Glow shader, slot 3 is used as an emissive map. But when a mesh uses the Skin shader, the same slot is used for skin tint. Be sure to select the proper [[#Shader types|shader type]], and activate the desired shader flags, for your model to be displayed correctly.
  
[[File:TextureSlots03.png]]
+
Textures are applied based on the [[AU:UV Unwrapping|UV map]] created during 3D modeling. Following [https://www.notion.so/UV-Mapping-Best-Practices-eefa3731217c4c65a907d1990939974f UV Mapping Best Practices] will help to prevent errors in your model.
  
{| class="wikitable"
+
{| class="wikitable" style="clear:both; width:90%; margin:1em auto"
! Number !! Name !! Use !! naming convention !!
+
|+ Texture Slots Overview
 
|-
 
|-
| SLOT 1 || diffuse map || diffuse (RGB) + transparency (Alpha) || d.dds ||
+
! Texture Slot !! Name !! RGB Channel !! Alpha Channel !! Texture Suffix !! Suggested [https://www.reedbeta.com/blog/understanding-bcn-texture-compression-formats/ Compression] !! Suggested creation method
 
|-
 
|-
| SLOT 2 || normal map || normal (RGB) + greyscale Specular (Alpha) || n.dds ||
+
| SLOT 1 || Diffuse map || Diffuse map (base color and ambient occlusion) || (optional) transparency map  || (no suffix) || BC1 (no Alpha), BC7<sup>[[#Notes|[a] ]]</sup> for RGBA || Base Color and additional contrast, darkness, desaturation
 
|-
 
|-
| SLOT 3 || glow map || emissive (RGB) / subsurface color (RGB) || sk.dds ||
+
| SLOT 2 || Normal map || Normal map || Grayscale specular map || _n.dds || BC7<sup>[[#Notes|[a] ]]</sup> || normal map similar to PBR, for specularity in your alpha channel invert a roughness map or insert a PBR specularity. Black is zero reflection, White full.
 
|-
 
|-
| SLOT 4 || bump map || greyscale height / parallax (RGB) || g.dds ||
+
| SLOT 3 || Glow map / Skin Tint || Emissive / Skin Tint || none || _g.dds / _sk.dds || BC1 || Color map.
 
|-
 
|-
| SLOT 5 || env. map / cube map || environment (mirror) / cube map (RGB) || e.dds ||
+
| SLOT 4 || Bump map || Grayscale height or parallax || none || _p.dds || BC4<sup>[[#Notes|[b] ]]</sup> || Used for depth levels in parallax shader (broken in vanilla Skyrim) and Multilayer Parallax.
 
|-
 
|-
| SLOT 6 || material map || environment / reflection mask (RGB) || m.dds ||
+
| SLOT 5 || Cube map || Cube map || none || _e.dds || BC1 || Ambient metallic color reflection of light.
 
|-
 
|-
| SLOT 7 || - map || inner layer diffuse (RGB) + inner layer depth (Alpha) || -.dds ||
+
| SLOT 6 || Environment Mask || Environment mask || none || _m.dds or _em.dds || BC4<sup>[[#Notes|[b] ]]</sup> || Environment map mask. Black is no environment map and white is full intensity environment map (refer to SLOT 5 for environment map).
 
|-
 
|-
| SLOT 8 || sst.m. || subsurface teint outer colour || s.dds ||
+
| SLOT 7 || Inner layer map || Inner layer diffuse || Inner layer depth / none || _i.dds || BC7<sup>[[#Notes|[a] ]]</sup> || For inner layer depth, black is minimum depth, white is maximum depth.
 
|-
 
|-
| SLOT 9 || - || - || - ||
+
| SLOT 8 || Subsurface Tint / Specular / Backlight map || Subsurface tint outer color / Specular map / Backlight map || none || (no convention) / _s.dds / _b.dds || BC1 || Subsurface tint adds a tint to the outer layer (an effect similar to rim lighting). This slot is also used for the specular map for meshes that use model space normals (NPCs). It can also be used for an RGB backlight map.
|}  
+
|}
 +
<div id="Notes" style="font-size:89%; text-align:center">
 +
: <small>[a]</small> - BC7 is not supported by Oldrim/LE. If modding for LE, use BC3 here.
 +
: <small>[b]</small> - BC4 is not supported by Oldrim/LE. If modding for LE, use BC1 here.
 +
</div>
  
==== Diffuse Map (Slot 1 of the Texture Set) ====
+
===Diffuse Map (Slot 1)===
 
This texture is the base texture of the mesh and contains the main coloring your texture will use as well as the transparency information in the alpha channel. All other textures will only be detail additions and effects.
 
This texture is the base texture of the mesh and contains the main coloring your texture will use as well as the transparency information in the alpha channel. All other textures will only be detail additions and effects.
 
* Compression:
 
* Compression:
** Use DXT1 if transparency is not needed.
+
** Use BC1 if transparency is not needed, or if only full transparency is needed.
** Use DXT3 if only full transparency is needed.
+
** Use BC3 or BC7 if the texture needs smooth partial transparency.
** Use DXT5 if the texture needs partial transparency.
 
  
 
* Required properties:
 
* Required properties:
Line 64: Line 71:
 
*Suffix: none
 
*Suffix: none
  
The NiAlphaProperty
+
=== Normal Map (Slot 2) ===
 +
The normal map adds the illusion of depth and detail to a mesh, while keeping the poly count low. Normal maps are [[AU:baking|baked]] from a high poly onto a low poly model, either with [[Arcane_University:3D_Art#3D_baking_programs|xNormal or a texture program]]. Learn more universal information on normal maps at [https://www.notion.so/Mesh-Maps-Explained-421c1c7b3c504020bde8a3d83f4ba4af Mesh Maps Explained] and [http://wiki.polycount.com/wiki/Normal_Map_Technical_Details Normal Map on Polycount Wiki].
  
Click the flag icon next to flags to view the settings.
 
  
Enable Blending should be checked
+
'''The Alpha Channel of the Normal Map'''
For Alpha Blending
 
Source Blend Mode: Src Alpha
 
Destination Blend Mode: Inv Src Alpha
 
For Additive Blending
 
Source Blend Mode: One
 
Destination Blend Mode: One
 
For Multiplicative Blending
 
Source Blend Mode: Zero
 
Destination Blend Mode: Src Color
 
For 2x Multiplicative Blending
 
Source Blend Mode: Dst Color
 
Destination Blend Mode: Src Color
 
For Alpha Testing check Enable Testing
 
Alpha Test Function sets how transparency channel grey values (0 to 255 or black to white) will be compared to the Alpha Test Threshold value to determine what is opaque
 
Less or Equal: Lighter will be more transparent
 
Greater or Equal: Darker will be more transparent
 
Alpha Test Threshold: Value from 0 to 255 (black to white)
 
Color Blending
 
  
'''Color Blending Equation'''
+
While the ''alpha channel'' in a .png image usually controls ''transparency'', it is not the case for DDS normal maps. The alpha channel instead decides how bright or "glossy" (specularity) that part of the mesh will be in-game. The alpha channel is a greyscale map, where black is minimum intensity with no specular highlight, white is maximum intensity, and grey is a varying degree of intensity. You can use a Specular map or an inverted Roughness map as the greyscale map in the alpha channel to enable this effect. Watch [https://wiki.beyondskyrim.org/w/images/e/ed/Specular_to_Normal_Alpha_Channel.gif how to use specular as alpha].
  
(Source * SourceBlendMode) + (Destination * DestinationBlendMode)
 
 
“Source” is the color of the model materials in that pixel before blending; “Destination” is the color of what is behind the model in that same pixel before blending; The two values are modified by the value of the blend mode in that same pixel, then they are added together.
 
 
'''Blend Modes''' (a.k.a. Blend Factor)
 
  
* One: multiply by one (no modification)
+
* Compression: Use BC3 or BC7 because of the importance of the alpha layer in this file. Bethesda uses BC3 in all tangent space normal maps.
* Zero: multiply by zero
 
* Src Color: multiply by “Source”
 
* Inv Src Color: multiply by inverse “Source”
 
* Dst Color: multiply by “Destination”
 
* Inv Dst Color: multiply by inverse “Destination”
 
* Src Alpha: multiply by value of the model’s alpha channel (diffuse and vertex colors) present at that pixel
 
* Inv Src Alpha: multiply by inverse value of the model’s alpha channel (diffuse and vertex colors)present at that pixel
 
* Dst Alpha: multiply by value of the background model’s alpha channel (diffuse and vertex colors)present at that pixel
 
* Inv Dst Alpha: multiply by inverse value of the background model’s alpha channel (diffuse and vertex colors)present at that pixel
 
* Additional information on color blending.
 
 
 
==== Normal Map (Slot 2 of the Texture Set) ====
 
The normal map, very similar to a bump map, will add the illusion of depth to the mesh. This is accomplished by creating varying shades of violet using various software including Mudbox, Zbrush, xNormal, Maya, the Gimp normal map plugin, or the Nvidia normal map plugin for Photoshop. Here is a video tutorial for creating high quality normal maps with ZBrush. The shader will then use the violet levels to determine the light levels for the texture, bending it if you wish, giving you what looks like height and depth details to the mesh. Model Space Normal files created by Bethesda have the suffix _msn and are normal maps with no alpha channel. I prefer to use _n tangent space normal maps with the alpha channel instead of using another image and more video ram. I personally find the ability to add a specular alpha too good a thing to pass up. It is important that NiTriShapeData > BS Num UV Sets is set to 4097 in NifSkope. If it is not, the Creation Kit, Nifskope, and the game itself will not display the Normal Map properly in-game. The Alpha Channel of the Tangent Space Normal Map The tangent space normal map’s alpha channel will be ignored in the Skyrim game engine for transparency and instead, the intensity of the different greyscale levels will determine how bright (specularity) that part of the mesh will be in-game. Black is minimum intensity, no specular highlight. White is maximum intensity. Intensity increases as shade approach white. A quick and dirty way to make this brightness mask is to take your diffuse map and darken it substantially, then copy it in to the alpha channel of the normal map in Gimp or Photoshop.
 
 
 
* Compression: Use DXT5 because of the importance of the alpha layer in this file. Bethesda uses DXT5 in all tangent space normal maps that I have observed.
 
 
* Required properties:
 
* Required properties:
** NiTriShapeData >BS Num UV Sets = 4097
+
** NiTriShapeData > BS Num UV Sets = 4097
 
** NiTriShapeData > Has Normals = yes
 
** NiTriShapeData > Has Normals = yes
 
** BSLightingShaderProperty > Shader Flags 1: SLSF1_Specular
 
** BSLightingShaderProperty > Shader Flags 1: SLSF1_Specular
Line 122: Line 91:
 
* Suffix: _n:  
 
* Suffix: _n:  
  
''' Suffix: _n: Tangent Space Normal Map'''
+
'''Suffix: _n: Tangent Space Normal Map'''
Required to use the alpha layer specular map. Tangent space normal maps are easily recognized by their mostly blue appearance. Tangent space normals almost always look bluish because normals in tangent space are always considered “up” (coordinates 0, 0, 1 ), even if in world space this is not true. The normals mapped on this triangle are thus encoded, and that’s the key point, relatively to ( 0, 0, 1 ). Because most normals are majorly “up”, and since the vector ( 0, 0, 1 ) is colorized as blue-purple-ish, the result is a blue-purple-ish normal map. The benefits of tangent space maps are the removal of the restrictions imposed by World Space and Object Space normal maps. Tangent Space normal maps can rotate and deform, therefore they are ideal for characters or objects that need to have vertex deformation, like water or tree limbs.
+
Also called Normal Map. Required to use the alpha layer specular map. Tangent space normal maps are easily recognized by their mostly blue appearance. Tangent space normals almost always look bluish because normals in tangent space are always considered “up” (coordinates 0, 0, 1 ), even if in world space this is not true. The normals mapped on this triangle are thus encoded, and that’s the key point, relatively to ( 0, 0, 1 ). Because most normals are majorly “up”, and since the vector ( 0, 0, 1 ) is colorized as blue-purple-ish, the result is a blue-purple-ish normal map. The benefits of tangent space maps are the removal of the restrictions imposed by World Space and Object Space normal maps. Tangent Space normal maps can rotate and deform, therefore they are ideal for characters or objects that need to have vertex deformation, like water or tree limbs.
  
  
Line 129: Line 98:
 
Does not have a specular alpha, SLSF1_Specular must be false. Slot 8 can contain a specular map if model space normals are used. Object Space normal maps can be moved, but the vertices of the mesh cannot be deformed or the shading is wrong. Object space normals are best for things that can move, but not deform, like swords, shields, doors, etc. Also note that the Creation Kit expects the normal map to be present for the mesh and will give an error message if not present.
 
Does not have a specular alpha, SLSF1_Specular must be false. Slot 8 can contain a specular map if model space normals are used. Object Space normal maps can be moved, but the vertices of the mesh cannot be deformed or the shading is wrong. Object space normals are best for things that can move, but not deform, like swords, shields, doors, etc. Also note that the Creation Kit expects the normal map to be present for the mesh and will give an error message if not present.
  
==== Emissive (glow) Map (Slot 3 of the Texture Set) ====
+
=== Emissive (glow) Map (Slot 3) ===
 
This slot can either be used for an Emissive Map or for a Subsurface Color Map which is used in the MultiLayer Parallax section below. The Emissive Map texture will add lighting to the mesh based on a few settings being set. The game will glow any color that you use / add but ignore black making this a very easy texture to apply. However, because you need to use Emissive Color for the glow base it may wash out the texture color.  You may need to try different settings for this color but it will most often work fine if you use similar colors or set Emissive Color to a greyscale color. Soft Lighting, also called wrapped diffuse adds a glow through the object to simulate light being diffused and passing through the object. Good for simulating semi-transparency on objects such as leaves. Rim lighting is only visible when light is on the opposite side of the mesh and simulates light bending around the object and lighting it at the edges.
 
This slot can either be used for an Emissive Map or for a Subsurface Color Map which is used in the MultiLayer Parallax section below. The Emissive Map texture will add lighting to the mesh based on a few settings being set. The game will glow any color that you use / add but ignore black making this a very easy texture to apply. However, because you need to use Emissive Color for the glow base it may wash out the texture color.  You may need to try different settings for this color but it will most often work fine if you use similar colors or set Emissive Color to a greyscale color. Soft Lighting, also called wrapped diffuse adds a glow through the object to simulate light being diffused and passing through the object. Good for simulating semi-transparency on objects such as leaves. Rim lighting is only visible when light is on the opposite side of the mesh and simulates light bending around the object and lighting it at the edges.
  
* Compression: DXT1
+
* Compression: BC1
 
* Required properties:
 
* Required properties:
 
** BSLightingShaderProperty > Shader Type: Glow Shader
 
** BSLightingShaderProperty > Shader Type: Glow Shader
Line 149: Line 118:
 
*Suffix: _g
 
*Suffix: _g
  
==== Height / Parallax Map (Slot 4 of the Texture Set) ====
+
=== Height / Parallax Map (Slot 4) ===
This slot is used for a Height/Parallax Map. This is different from MultiLayer Parallax. This is a greyscale image in RGB format. Height is determined by the darkness or lightness of each pixel as follows:
+
This slot is used for a true Height/Parallax Map, different from the MultiLayer Parallax shader. It does not function in vanilla SSE, so it requires the [https://www.nexusmods.com/skyrimspecialedition/mods/31963 SSE Parallax Shader Fix] SKSE Plugin, or ENB. This is a greyscale image in RGB format. Height is determined by the darkness or lightness of each pixel as follows:
 
* Mid grey (RGB 127,127,127) is zero depth and height, Black is maximum depth, White is maximum height.
 
* Mid grey (RGB 127,127,127) is zero depth and height, Black is maximum depth, White is maximum height.
* Compression: DXT1
+
* Compression: BC1
 
* Required Properties:
 
* Required Properties:
* An ENB is required for this texture to function properly.
 
 
** BSLightingShaderProperty > Shader Flags 1: SLSF1_Parallax
 
** BSLightingShaderProperty > Shader Flags 1: SLSF1_Parallax
 
* Shader Type: Heightmap
 
* Shader Type: Heightmap
 
* Suffix: _p
 
* Suffix: _p
  
==== Environment / Cube Map (Slot 5 of the Texture Set) ====
+
=== Environment / Cube Map (Slot 5) ===
 
Environment/Cube Maps more or less add another layer of textures and can help get a more detailed look to your mesh. Cube mapping is preferred over other methods of environment mapping because of its relative simplicity. Also, cube mapping produces results that are similar to those obtained by high quality, slow rendering, but takes much less processing power – the moderate reduction in quality is compensated for by large gains in efficiency. Also, cube mapping provides a much larger capacity to support real-time rendering of reflections relative to other mapping methods because the combination of inefficiency and viewpoint dependency severely limit the ability of these mapping techniques to be applied when there is a consistently changing viewpoint. These maps are a bit different than other one layered textures: A cube use 6 faces, counting 2 faces for each axis, xyz. Each face can be calculated with positive and negative x, y and z. They are sorted from +x, -x, +y, -y, +z and lastly -z. Each of these would be their own layer in an image editor, for instance, Gimp or Photoshop.
 
Environment/Cube Maps more or less add another layer of textures and can help get a more detailed look to your mesh. Cube mapping is preferred over other methods of environment mapping because of its relative simplicity. Also, cube mapping produces results that are similar to those obtained by high quality, slow rendering, but takes much less processing power – the moderate reduction in quality is compensated for by large gains in efficiency. Also, cube mapping provides a much larger capacity to support real-time rendering of reflections relative to other mapping methods because the combination of inefficiency and viewpoint dependency severely limit the ability of these mapping techniques to be applied when there is a consistently changing viewpoint. These maps are a bit different than other one layered textures: A cube use 6 faces, counting 2 faces for each axis, xyz. Each face can be calculated with positive and negative x, y and z. They are sorted from +x, -x, +y, -y, +z and lastly -z. Each of these would be their own layer in an image editor, for instance, Gimp or Photoshop.
  
* Compression: DXT1
+
* Compression: BC1
 
* Required Properties:
 
* Required Properties:
 
** BSLightingShaderProperty > Shader Type: Environment Map
 
** BSLightingShaderProperty > Shader Type: Environment Map
Line 171: Line 139:
 
* Suffix: _e
 
* Suffix: _e
  
==== Greyscale / metallic cube map (Slot 6 of the Texture Set) ====
+
=== Greyscale / metallic cube mask (Slot 6) ===
 
Environment/Cube Mask is a Greyscale Image. Simply a lighting control texture sometimes referred to as a specular map with the purpose to soften or diminish the level of light affecting the mesh reflection. Brightness of individual pixels determines the effect: white will reflect all light and black will reflect no light.
 
Environment/Cube Mask is a Greyscale Image. Simply a lighting control texture sometimes referred to as a specular map with the purpose to soften or diminish the level of light affecting the mesh reflection. Brightness of individual pixels determines the effect: white will reflect all light and black will reflect no light.
* Compression: DXT1
+
* Compression: BC1
 
* Required Properties:
 
* Required Properties:
 
** An environment/cube map is required.
 
** An environment/cube map is required.
Line 181: Line 149:
 
** BSLightingShaderProperty > Environmental Map Scale, 1 is normal intensity, less than 1 is lower intensity, greater than 1 is higher intensity,  
 
** BSLightingShaderProperty > Environmental Map Scale, 1 is normal intensity, less than 1 is lower intensity, greater than 1 is higher intensity,  
 
** Black is minimum intensity, environment/cube map has no effect in these areas, White is maximum intensity, Intensity increases as shade approaches white
 
** Black is minimum intensity, environment/cube map has no effect in these areas, White is maximum intensity, Intensity increases as shade approaches white
* Suffix: _m
+
* Suffix: _m or _em
  
==== Subsurface Tint Map (Slot 7 of the Texture Set) ====
+
=== Subsurface Tint Map (Slot 7) ===
 
This slot is also used for Inner Layer Diffuse and Inner Layer Depth maps in MultiLayer Parallax which will be detailed below. Subsurface tint maps are used for subsurface scattering. This is a rendering effect that simulates the diffusion of light inside a translucent medium. The effect can be seen as an extension on the principles of translucency and is appropriate for realistically simulating a wide range of materials including wax, marble, liquids (like milk), plant leaves, fruit, snow, and most importantly, human skin.
 
This slot is also used for Inner Layer Diffuse and Inner Layer Depth maps in MultiLayer Parallax which will be detailed below. Subsurface tint maps are used for subsurface scattering. This is a rendering effect that simulates the diffusion of light inside a translucent medium. The effect can be seen as an extension on the principles of translucency and is appropriate for realistically simulating a wide range of materials including wax, marble, liquids (like milk), plant leaves, fruit, snow, and most importantly, human skin.
* Compression: DXT1
+
* Compression: BC1
 
* Required Properties:
 
* Required Properties:
 
** BSLightingShaderProperty > Shader Type: Skin Tint
 
** BSLightingShaderProperty > Shader Type: Skin Tint
Line 193: Line 161:
 
* Suffix: _s
 
* Suffix: _s
  
==== Backlight Map (Slot 8 of the Texture Set) ====
+
=== Backlight Map (Slot 8) ===
 
Back lighting fills in the surface opposite a light. This is useful for faking translucency, like showing the bones in a dragon’s wings yet letting light bleed through the skin. The texture can be colored but like glow maps a high emissive value will wash that color out.
 
Back lighting fills in the surface opposite a light. This is useful for faking translucency, like showing the bones in a dragon’s wings yet letting light bleed through the skin. The texture can be colored but like glow maps a high emissive value will wash that color out.
* Compression: DXT1
+
* Compression: BC1
 
* Required properties:
 
* Required properties:
 
** BSLightingShaderProperty > Shader Flags 2: SLSF2_Back_Lighting
 
** BSLightingShaderProperty > Shader Flags 2: SLSF2_Back_Lighting
Line 204: Line 172:
 
* Suffix: _b or _bl
 
* Suffix: _b or _bl
  
==== The unused 9th slot ====
+
=== Slot 9 (Unused) ===
 
Slot09 – Currently Unused.
 
Slot09 – Currently Unused.
  
=== Shader Types & corresponding Texture Sets ===
+
== Shader types ==
 
[[File:BSshadertypes01.png]]  
 
[[File:BSshadertypes01.png]]  
  
Here you can see the available shader types of a BSLightingshaderproperty.They also need specific shader flags to be set and specific texture maps. Some are essential, others optional. These are all the available Shader Flags for Skyrim:
+
Here you can see the available shader types of a BSLightingShaderProperty. They also need specific shader flags to be set and specific texture maps. Some are essential, others optional. These are all the available Shader Flags for Skyrim:
  
 
[[File:BSshadersFlagsExport.png]]  
 
[[File:BSshadersFlagsExport.png]]  
  
Commonly used in Skyrim are Default shader type (“0”) and Environment Map shader type (“1”). Green shows you those who are essential for exporting a default type mesh successfully, the minimum to be set. Pink are those commonly used additional options for Lighting, environment mapping, or weighting (rigging), glow effects. There are more advanced features like multilayer parallax, but the intention of this short tutorial is, to give people a quick and solid introduction into the rendering settings for meshes used in Skyrim, which are unlike the more recent PBR Systems. You set your mesh shader property type in BSLightingshaderproperties. Note that each Nitrishape can only have one shader type and a small range of optional shader flags and use specific controllers (properties seen below).
+
Commonly used in Skyrim are Default shader type (“0”) and Environment Map shader type (“1”). Green shows you those who are essential for exporting a default type mesh successfully, the minimum to be set. Pink are those commonly used additional options for Lighting, environment mapping, or weighting (rigging), glow effects. There are more advanced features like multilayer parallax, but the intention of this short tutorial is, to give people a quick and solid introduction into the rendering settings for meshes used in Skyrim, which are unlike the more recent PBR Systems. You set your mesh shader property type in BSLightingShaderProperties. Note that each NiTriShape can only have one shader type and a small range of optional shader flags and use specific controllers (properties seen below).
  
 
[[File:BScontrollers01.png]]
 
[[File:BScontrollers01.png]]
  
 
* The standard for the '''Glossiness''' value is 100. It ranged between 0 and 999.
 
* The standard for the '''Glossiness''' value is 100. It ranged between 0 and 999.
* '''Specular Strenght''' ranges from 0 to 10 but 2 would already be very strong,  1 being the default.
+
* '''Specular Strength''' ranges from 0 to 10 but 2 would already be very strong,  1 being the default.
* '''Refraction Strenght''' ranges from 0 to 1. 1 being absolute transparency.
+
* '''Refraction Strength''' ranges from 0 to 1. 1 being absolute transparency.
 
* '''Alpha''' also does transparency but in a different way.
 
* '''Alpha''' also does transparency but in a different way.
 
* '''Emissive Colour''' and '''Specular Colour''' are the RGB values that are shining or reflecting when looking straight at the mesh.
 
* '''Emissive Colour''' and '''Specular Colour''' are the RGB values that are shining or reflecting when looking straight at the mesh.
 
* '''UV Scale''' is the scaling size of the UV map. You can right-click on your mesh in the render window and chose textures / UV map and manually edit it, rotate, and scale it.
 
* '''UV Scale''' is the scaling size of the UV map. You can right-click on your mesh in the render window and chose textures / UV map and manually edit it, rotate, and scale it.
  
The most commonly used BSLightingShaderProperties are Default shader type (“0”) and Environment Map shader type (“1”). You set your mesh shader property type in BSLightingshaderproperties. Note that each Nitrishape can only have one shader type and a small range of optional shader flags and use specific controllers(see below). But, if needed, you can simply use multiple Nitrishapes combined on top of each other. As an example, it might make sense to split your mesh into subsections by material (metal, leather) and export each as a different Nitrishape (first sublevel) into the same mesh. Consider a leather armor for instance. I would suggest having an organic leather/cloth part (which usually absorbs light to a high degree and would use the default shader type) and the metal elements (which would reflect light stronger and profit from cube maps used in the environment map shader type).
+
The most commonly used BSLightingShaderProperties are Default shader type (“0”) and Environment Map shader type (“1”). You set your mesh shader property type in BSLightingShaderProperties. Note that each NiTriShape can only have one shader type and a small range of optional shader flags and use specific controllers(see below). But, if needed, you can simply use multiple NiTriShapes combined on top of each other. As an example, it might make sense to split your mesh into subsections by material (metal, leather) and export each as a different NiTriShape (first sublevel) into the same mesh. Consider a leather armor for instance. I would suggest having an organic leather/cloth part (which usually absorbs light to a high degree and would use the default shader type) and the metal elements (which would reflect light stronger and profit from cube maps used in the environment map shader type).
  
 
====Default Shader====
 
====Default Shader====
Line 250: Line 218:
 
* used for: Assets with colour, height, and specularity and additional shininess or gloss.
 
* used for: Assets with colour, height, and specularity and additional shininess or gloss.
 
* common examples: Metals, Chitin, Ore, Armours, Glass, Mirrors, Ice (more stable and consistent with ENBs than parallax)
 
* common examples: Metals, Chitin, Ore, Armours, Glass, Mirrors, Ice (more stable and consistent with ENBs than parallax)
* necessary slots: Slot1) base color/diffuse map AND Slot2) normal map with specularity in alpha channel (optional) AND environmental/cube map (slot 5) (DTX1, see DDS Texture files for details) AND optional: a material (m) map, that sets reflection (a bit like an additional specularity map with lower brightness, greyscale, see below)
+
* necessary slots: Slot 1) base color/diffuse map AND Slot 2) normal map with specularity in alpha channel (optional) AND environmental/cube map (slot 5) (DTX1, see DDS Texture files for details) AND optional: an environment mask (_m or _em), that sets which areas are reflective (Slot 6)
 
* necessary flags: SLSF1_Environment_Mapping, SLSF2_Glow_Map disabled
 
* necessary flags: SLSF1_Environment_Mapping, SLSF2_Glow_Map disabled
 
* controllers: Environmental Map Scale; 1 is normal intensity, less is lower intensity, greater is higher intensity.
 
* controllers: Environmental Map Scale; 1 is normal intensity, less is lower intensity, greater is higher intensity.
Line 266: Line 234:
 
A typical metal texture set for Skyrim: the rendering will make the diffuse appear much brighter. A lot of detail is being baked into the diffuse. Finally, the sword appears silver-metallic in the game engine.
 
A typical metal texture set for Skyrim: the rendering will make the diffuse appear much brighter. A lot of detail is being baked into the diffuse. Finally, the sword appears silver-metallic in the game engine.
  
=== Effect Properties ===
+
For how to work on the material map for the roughness and metallic shine, see https://www.youtube.com/watch?v=DWs9rDpA5tQ
Effect Properties are set by Bethesda, and the ability to create them without the appropriate tools are limited. However, if you understand the basic structure of nif formate meshes and have nifskope installed, it is easy to copy and paste branches to tweak and reuse the effects that you encounter in the vanilla files. There is quite a variety of usable effects, from animated textures to animated meshes over particle effects and vertex lighting. Many things can be realized with these basic effect types, given the number of controllers to modify them. Note that like with BSshaderproperties, BSEffectProperties are one level below Nitrishape Data and there can only be one of its kind in a Nitrishape, so you might want to use several Nitrishapes in your nif mesh (NiNode skinned rigs or BSfadenode for statics) if you need several effects. The general workflow would be, similar to how you can exchange shader properties, to:
+
 
 +
== Transparency ==
 +
Transparency is enabled for each NiTriShape by adding a NiAlphaProperty node.
 +
 
 +
=== Blending ===
 +
If partial transparency is desired, "Enable Blending" must be checked.
 +
 
 +
*For Alpha Blending:
 +
**Source Blend Mode: Src Alpha
 +
**Destination Blend Mode: Inv Src Alpha
 +
*For Additive Blending:
 +
**Source Blend Mode: One
 +
**Destination Blend Mode: One
 +
*For Multiplicative Blending:
 +
**Source Blend Mode: Zero
 +
**Destination Blend Mode: Src Color
 +
*For 2x Multiplicative Blending:
 +
**Source Blend Mode: Dst Color
 +
**Destination Blend Mode: Src Color
 +
 
 +
=== Alpha Testing ===
 +
For Alpha Testing, check "Enable Testing." The Alpha Test Function sets how transparency channel grey values (0 to 255 or black to white) will be compared to the Alpha Test Threshold value to determine the threshold at which pixels with partial transparency should be rendered as completely transparent.
 +
 
 +
This setting can also be modified at the CK object reference level, allowing a single nif to have variable levels of transparency. This is used most often in Skyrim to create objects with varying levels of decay, like rugs in Nordic Tombs.
 +
 
 +
:Less or Equal: Lighter will be more transparent
 +
:Greater or Equal: Darker will be more transparent
 +
:Alpha Test Threshold: Value from 0 to 255 (black to white)
 +
 
 +
=== Color Blending ===
 +
 
 +
'''Color Blending Equation'''
 +
 
 +
:(Source * SourceBlendMode) + (Destination * DestinationBlendMode)
 +
 
 +
"Source" is the color of the model materials in that pixel before blending. "Destination" is the color of what is behind the model in that same pixel before blending. These two values are modified by the value of the blend mode in that same pixel, then they are added together.
 +
 
 +
'''Blend Modes''' (a.k.a. Blend Factor)
 +
 
 +
* One: multiply by one (no modification)
 +
* Zero: multiply by zero
 +
* Src Color: multiply by “Source”
 +
* Inv Src Color: multiply by inverse “Source”
 +
* Dst Color: multiply by “Destination”
 +
* Inv Dst Color: multiply by inverse “Destination”
 +
* Src Alpha: multiply by value of the model’s alpha channel (diffuse and vertex colors) present at that pixel
 +
* Inv Src Alpha: multiply by inverse value of the model’s alpha channel (diffuse and vertex colors) present at that pixel
 +
* Dst Alpha: multiply by value of the background model’s alpha channel (diffuse and vertex colors) present at that pixel
 +
* Inv Dst Alpha: multiply by inverse value of the background model’s alpha channel (diffuse and vertex colors) present at that pixel
 +
 
 +
== Effect Properties ==
 +
Effect Properties are set by Bethesda, and the ability to create them without the appropriate tools are limited. However, if you understand the basic structure of nif format meshes and have NifSkope installed, it is easy to copy and paste branches to tweak and reuse the effects that you encounter in the vanilla files. There is quite a variety of usable effects, from animated textures to animated meshes over particle effects and vertex lighting. Many things can be realized with these basic effect types, given the number of controllers to modify them. Note that like with BSShaderProperties, BSEffectProperties are one level below NiTriShape Data and there can only be one of its kind in a NiTriShape, so you might want to use several NiTriShapes in your nif mesh (NiNode skinned rigs or BSFadeNode for statics) if you need several effects. The general workflow would be, similar to how you can exchange shader properties, to:
 
* search through meshes for an effect property that supports your vision
 
* search through meshes for an effect property that supports your vision
 
* copy the branch of the effect property
 
* copy the branch of the effect property
 
* remove the branch in the new mesh that is to be replaced
 
* remove the branch in the new mesh that is to be replaced
* paste the branch that you copied there in the Nitrishape
+
* paste the branch that you copied there in the NiTriShape
 
* tweak the controller settings (numerical values) and set up textures
 
* tweak the controller settings (numerical values) and set up textures
* check if you can / have to sanitize the mesh with Nifskope spells
+
* check if you can / have to sanitize the mesh with NifSkope spells
 
* check placement and CK implementation, Test it in-game
 
* check placement and CK implementation, Test it in-game
  
Line 287: Line 306:
 
* Rain Clouds (you can also emulate Thunder Storms, Animated Doors etc)
 
* Rain Clouds (you can also emulate Thunder Storms, Animated Doors etc)
 
[[File:nifeffects1.png]]
 
[[File:nifeffects1.png]]
* Vulcanic Smoke (you can also emulate floating textures like water, lava ...)
+
* Volcanic Smoke (you can also emulate floating textures like water, lava ...)
 
[[File:nifeffects2.png]]
 
[[File:nifeffects2.png]]
 
[[File:nifeffects3.png]]
 
[[File:nifeffects3.png]]
Line 293: Line 312:
 
[[File:nifeffects4.png]]
 
[[File:nifeffects4.png]]
  
==BSXFlags node==
+
==Metadata==
The BSXFlags node goes inside of the root node of the nif, in most cases it will be the first one in the root's children. It serves to define the behaviour of the object in Skyrim, the flag that corresponds to each thing varies is an arbitraty number, and must be inputed as it is depending on the case. The known BSXFlags are as follows:
+
===<span id="BSXFlags node"></span>BSXFlags===
 +
The BSXFlags node goes inside of the root node of the nif. In most cases it will be the first one in the root's children. It contains a series of flags that activate different properties of the object in Skyrim. These properties can be accessed and selected by clicking the small flag icon, the total number is the sum of the selected flag values. The list of possible flags is as follows:
 +
{| class="wikitable"
 +
! Bit/Number !! Name !! Description
 +
|-
 +
| Bit 0 (1) || Animated || Necessary for any animation on this asset to play
 +
|-
 +
| Bit 1 (2) || Havok || Enable collision
 +
|-
 +
| Bit 2 (4) || Ragdoll || Used by skeleton nifs
 +
|-
 +
| Bit 3 (8) || Complex || Has more than one bhkCollisionObject
 +
|-
 +
| Bit 4 (16) || Addon || Necessary for any addon node (e.g. candle flame) to appear in game
 +
|-
 +
| Bit 5 (32) || Editor marker || Necessary for an editor marker on this asset to appear in the CK
 +
|-
 +
| Bit 6 (64) || Dynamic || Asset uses Havok physics (affected by gravity, can move around)
 +
|-
 +
| Bit 7 (128) || Articulated || Has a single bhkCollisionObject, or a single kinematic chain
 +
|-
 +
| Bit 8 (256) || Needs transform updates || Never used in vanilla Skyrim or DLCs
 +
|-
 +
| Bit 9 (512) || External emit || Used by assets emitting light
 +
|}   
 +
 
 +
{{note|Bit 7 (Articulated) is influenced by a NiSwitchNode, if one is present. Even if multiple branches of the switch node have collision, if a single collision object or kinematic chain is to be displayed at a time, this bit will be set.}}
  
 +
This is a cheat sheet of some common BSXFlags values used in vanilla objects:
 
{| class="wikitable"
 
{| class="wikitable"
 
! Number !! Use !! Description
 
! Number !! Use !! Description
 
|-
 
|-
| 130 || Statics || The player won't be able to interact with the object aside from colliding with it, e.g. Tables, fireplaces, rocks ||
+
| 130 || Statics || The player won't be able to interact with the object aside from colliding with it, e.g. Tables, fireplaces, rocks
 +
|-
 +
| 131 || Animated Statics || The same as statics, just with animations, e.g. Chests, doors
 
|-
 
|-
| 651 || Cooking station || Furniture, will trigger the cooking animation. e.g. cooking spits ||
+
| 194 || Clutter || Havok is activated on these objects, meaning that they have physics applied, e.g. Clutter, weapons, armor ground items
|}  
+
|}
== Collisions ==
 
 
 
== Mass Center ==
 
  
== Physical Material of the NIF ==
+
=== Inventory Marker ===
  
== General Optimizations of the NIF ==
+
The inventory marker (BSInvMarker) block determines the rotation and zoom of an item when viewed in the inventory. Rotation X, Y and Z specify the clockwise rotation in ''radians*1000'' around that axis, when viewed from the positive side of that axis. The standard view (no rotations) in the inventory is viewing from the positive Y axis. Increasing the zoom value makes the item appear larger in the inventory, decreasing it makes it smaller.
  
=== Update Tangents ===  
+
== Collision ==
=== Reorder Blocks ===
+
{{main|[[Arcane University:Mesh Collisions]]}}
=== Sanitize Blocknames ===
 
  
 +
Collision meshes are used to make objects solid in the Creation Engine. A nif can have a single collision mesh, or many. They can be static or moving. The collision settings are also what make the object affected by physics. They determine what parts of an object are interactable. They are typically simpler than the visible meshes, being made up of fewer vertices, since they are invisible and do not need small detail.
  
----
+
== See Also ==
For details on textures, check [[Arcane_University:DDS_Data_Format|DDS Data Format]]
+
* [[AU:Nif Implementation|Nif Implementation]]: Tutorials on making nifs work in Skyrim.
 +
* [[Arcane_University:DDS_Data_Format|DDS Data Format]]: Information on the DDS format, used for textures.
 +
*[https://forums.nexusmods.com/index.php?/topic/1188259-bslightingshaderproperty-basics/ BSLightingShaderProperty Basics] explains further about BSLightingShaderProperty node and it's uses. Includes image examples.
  
[[Category:Arcane_University]]
+
[[Category:Arcane_University]][[Category:Arcane_University-3D_Art]]
 
[[Category:Data_Format]]
 
[[Category:Data_Format]]

Latest revision as of 01:08, 18 October 2023

< Arcane University:Implementation: Nif Implementation

NIF stands for "NetImmerse Format," which is a file type that was created for the NetImmerse engine in 1997. This later morphed into the Gamebryo Engine (used for Morrowind, Oblivion, and Fallout 3), which in turn was the basis for the Creation Engine, used by games such as Skyrim, Fallout 4, and Fallout 76. Much more than simple 3D mesh files, Nifs can also contain complex shader and texturing information, as well as character rigs, animations, collison meshes, physics properties, and other information that is passed to the game engine. This article details the structure and workings of Nif files as they are used for Skyrim.

General NIF structure[edit]

Use this option in NifSkope if the blocks are not shown in tree format.
An example nif block structure.

Nifs are organized into blocks or nodes arranged in a hierarchy or "tree." Each block has various properties that define how it functions in the game.

The root node always has a block ID of 0. It is most commonly a BSFadeNode (static bodies), a NiNode (skinned rigged meshes like armors), or a BSLeafAnim/tree node (plants). The root node will usually have attached metadata blocks that activate other nif properties like animation, Havok physics, and inventory display. 3D Meshes are represented by TriShapes. The surface material is defined by a shader property block, either a Lighting Shader or an Effect Shader. Animations are defined in Controller blocks, or in child nodes of the shader property.

TriShapes[edit]

A NiTriShape can have the following child properties among others:

  • NiTriShapeData: the actual mesh data (vertices, normals, tangents, UV map).
  • Shader Property (BSLightingShaderProperty or BSEffectShaderProperty): holds lighting and texture information.
  • NiAlphaProperty: tells the game how to handle transparency in the mesh, if any.
  • BSDismemberSkinInstance: only present in skinned meshes like armor. It contains the vertex weighting to handle limbs being dismembered from the base mesh, and deform during animation.

BSTriShapes, used in Skyrim Special Edition, combine the NiTriShape and NiTriShapeData into a single block. They are not widely supported by nif import and export tools, and cannot be manipulated as easily within NifSkope. They can be converted back and forth by nif converter tools like Cathedral Assets Optimizer or SSE Nif Optimizer. However, LE nifs work fine in Special Edition, and do not need to be converted. In fact, SSE nifs use less precise values, so LE nifs are recommended regardless of which version of the game you are modding.

BSLODTriShapes are the same as NiTriShapes, except that they fade out some distance away. This is used in LE to make small details on architecture nifs fade out before it is replaced with an LOD model. This block has no effect in SSE (no parts fade out individually).

Texture Slots[edit]

NifSkope uses zero-based numbering, so the first slot is Slot 0, the normal map slot is Slot 1, etc.

All textures used by Skyrim are DDS (Direct Draw Surface) files (with a few exceptions, such as menu art). These textures are typically referenced in the BSShaderTextureSet block, as shown at right.

Some slots are reused for multiple different purposes. For example, when a mesh uses the Glow shader, slot 3 is used as an emissive map. But when a mesh uses the Skin shader, the same slot is used for skin tint. Be sure to select the proper shader type, and activate the desired shader flags, for your model to be displayed correctly.

Textures are applied based on the UV map created during 3D modeling. Following UV Mapping Best Practices will help to prevent errors in your model.

Texture Slots Overview
Texture Slot Name RGB Channel Alpha Channel Texture Suffix Suggested Compression Suggested creation method
SLOT 1 Diffuse map Diffuse map (base color and ambient occlusion) (optional) transparency map (no suffix) BC1 (no Alpha), BC7[a] for RGBA Base Color and additional contrast, darkness, desaturation
SLOT 2 Normal map Normal map Grayscale specular map _n.dds BC7[a] normal map similar to PBR, for specularity in your alpha channel invert a roughness map or insert a PBR specularity. Black is zero reflection, White full.
SLOT 3 Glow map / Skin Tint Emissive / Skin Tint none _g.dds / _sk.dds BC1 Color map.
SLOT 4 Bump map Grayscale height or parallax none _p.dds BC4[b] Used for depth levels in parallax shader (broken in vanilla Skyrim) and Multilayer Parallax.
SLOT 5 Cube map Cube map none _e.dds BC1 Ambient metallic color reflection of light.
SLOT 6 Environment Mask Environment mask none _m.dds or _em.dds BC4[b] Environment map mask. Black is no environment map and white is full intensity environment map (refer to SLOT 5 for environment map).
SLOT 7 Inner layer map Inner layer diffuse Inner layer depth / none _i.dds BC7[a] For inner layer depth, black is minimum depth, white is maximum depth.
SLOT 8 Subsurface Tint / Specular / Backlight map Subsurface tint outer color / Specular map / Backlight map none (no convention) / _s.dds / _b.dds BC1 Subsurface tint adds a tint to the outer layer (an effect similar to rim lighting). This slot is also used for the specular map for meshes that use model space normals (NPCs). It can also be used for an RGB backlight map.
[a] - BC7 is not supported by Oldrim/LE. If modding for LE, use BC3 here.
[b] - BC4 is not supported by Oldrim/LE. If modding for LE, use BC1 here.

Diffuse Map (Slot 1)[edit]

This texture is the base texture of the mesh and contains the main coloring your texture will use as well as the transparency information in the alpha channel. All other textures will only be detail additions and effects.

  • Compression:
    • Use BC1 if transparency is not needed, or if only full transparency is needed.
    • Use BC3 or BC7 if the texture needs smooth partial transparency.
  • Required properties:
    • For Alpha Transparency: Automatically enabled for outer layer if using MultiLayer Parallax shader, otherwise requires that a NiAlphaProperty be added to the NiTriShape (right-click the NiTriShape > Node > Attach Property > NiAlphaProperty)
    • NiTriShapeData > Has Vertex Colors
    • NiTriShapeData > Vertex Colors
  • Appearance Controller(s):
    • For Alpha Transparency: NiAlphaProperty > Flags (Click the flag to view settings)
    • BSLightingShaderProperty > Alpha, 0 is fully transparent (invisible), 1 is fully visible (opaque)
    • Transparency Map (Alpha Channel): Black is fully transparent (invisible) (dependent on NiAlphaProperty flag settings), White is fully visible (opaque) (dependent on NiAlphaProperty flag settings)
    • Transparency increases as shade approaches black (dependent on NiAlphaProperty flag settings)
  • Suffix: none

Normal Map (Slot 2)[edit]

The normal map adds the illusion of depth and detail to a mesh, while keeping the poly count low. Normal maps are baked from a high poly onto a low poly model, either with xNormal or a texture program. Learn more universal information on normal maps at Mesh Maps Explained and Normal Map on Polycount Wiki.


The Alpha Channel of the Normal Map

While the alpha channel in a .png image usually controls transparency, it is not the case for DDS normal maps. The alpha channel instead decides how bright or "glossy" (specularity) that part of the mesh will be in-game. The alpha channel is a greyscale map, where black is minimum intensity with no specular highlight, white is maximum intensity, and grey is a varying degree of intensity. You can use a Specular map or an inverted Roughness map as the greyscale map in the alpha channel to enable this effect. Watch how to use specular as alpha.


  • Compression: Use BC3 or BC7 because of the importance of the alpha layer in this file. Bethesda uses BC3 in all tangent space normal maps.
  • Required properties:
    • NiTriShapeData > BS Num UV Sets = 4097
    • NiTriShapeData > Has Normals = yes
    • BSLightingShaderProperty > Shader Flags 1: SLSF1_Specular
  • Appearance Controller(s)
    • BSLightingShaderProperty > Specular Strength, 1 is normal intensity, Less than 1 is lower intensity, Greater than 1 is higher intensity
    • BSLightingShaderProperty > Specular Color, The color of the specular highlight
    • BSLightingShaderProperty > Glossiness, Glossiness is the width of the specular highlight, 10 is a wide specular highlight, 50 is a thinner specular highlight, 100 is an even thinner specular highlight; Value ranges from 0 to 999
  • Suffix: _n:

Suffix: _n: Tangent Space Normal Map Also called Normal Map. Required to use the alpha layer specular map. Tangent space normal maps are easily recognized by their mostly blue appearance. Tangent space normals almost always look bluish because normals in tangent space are always considered “up” (coordinates 0, 0, 1 ), even if in world space this is not true. The normals mapped on this triangle are thus encoded, and that’s the key point, relatively to ( 0, 0, 1 ). Because most normals are majorly “up”, and since the vector ( 0, 0, 1 ) is colorized as blue-purple-ish, the result is a blue-purple-ish normal map. The benefits of tangent space maps are the removal of the restrictions imposed by World Space and Object Space normal maps. Tangent Space normal maps can rotate and deform, therefore they are ideal for characters or objects that need to have vertex deformation, like water or tree limbs.


Suffix: _msn: Model Space Normal Map Does not have a specular alpha, SLSF1_Specular must be false. Slot 8 can contain a specular map if model space normals are used. Object Space normal maps can be moved, but the vertices of the mesh cannot be deformed or the shading is wrong. Object space normals are best for things that can move, but not deform, like swords, shields, doors, etc. Also note that the Creation Kit expects the normal map to be present for the mesh and will give an error message if not present.

Emissive (glow) Map (Slot 3)[edit]

This slot can either be used for an Emissive Map or for a Subsurface Color Map which is used in the MultiLayer Parallax section below. The Emissive Map texture will add lighting to the mesh based on a few settings being set. The game will glow any color that you use / add but ignore black making this a very easy texture to apply. However, because you need to use Emissive Color for the glow base it may wash out the texture color. You may need to try different settings for this color but it will most often work fine if you use similar colors or set Emissive Color to a greyscale color. Soft Lighting, also called wrapped diffuse adds a glow through the object to simulate light being diffused and passing through the object. Good for simulating semi-transparency on objects such as leaves. Rim lighting is only visible when light is on the opposite side of the mesh and simulates light bending around the object and lighting it at the edges.

  • Compression: BC1
  • Required properties:
    • BSLightingShaderProperty > Shader Type: Glow Shader
    • BSLightingShaderProperty > Shader Flags 1: SLSF1_Own_Emit
    • SLSF1_Environment_Mapping disabled
    • BSLightingShaderProperty > Shader Flags 2: SLSF2_Glow_Map
    • For Soft Lighting: SLSF2_Soft_Lighting
    • For RIM Lighting: SLSF2_Rim_Lighting (Rim lighting overwrites soft lighting)
  • Appearance Controller(s):
    • BSLightingShaderProperty > Emissive Multiple (Glow intensity increases as emissive multiple increases)
    • BSLightingShaderProperty > Emissive Color
    • Soft Lighting Specific Lighting Effect 1:

Light begins in the center and higher values wrap the light further around the sides. Between 0-1 the effect also diminishes in strength such that 0.0 is completely off.

    • Rim Lighting Specific Lighting Effect 2:

Light begins on the edge and moves towards the center as the value increases. The lower the number, the more edges the light catches on. The higher the number, the sharper the effect appears.

  • Suffix: _g

Height / Parallax Map (Slot 4)[edit]

This slot is used for a true Height/Parallax Map, different from the MultiLayer Parallax shader. It does not function in vanilla SSE, so it requires the SSE Parallax Shader Fix SKSE Plugin, or ENB. This is a greyscale image in RGB format. Height is determined by the darkness or lightness of each pixel as follows:

  • Mid grey (RGB 127,127,127) is zero depth and height, Black is maximum depth, White is maximum height.
  • Compression: BC1
  • Required Properties:
    • BSLightingShaderProperty > Shader Flags 1: SLSF1_Parallax
  • Shader Type: Heightmap
  • Suffix: _p

Environment / Cube Map (Slot 5)[edit]

Environment/Cube Maps more or less add another layer of textures and can help get a more detailed look to your mesh. Cube mapping is preferred over other methods of environment mapping because of its relative simplicity. Also, cube mapping produces results that are similar to those obtained by high quality, slow rendering, but takes much less processing power – the moderate reduction in quality is compensated for by large gains in efficiency. Also, cube mapping provides a much larger capacity to support real-time rendering of reflections relative to other mapping methods because the combination of inefficiency and viewpoint dependency severely limit the ability of these mapping techniques to be applied when there is a consistently changing viewpoint. These maps are a bit different than other one layered textures: A cube use 6 faces, counting 2 faces for each axis, xyz. Each face can be calculated with positive and negative x, y and z. They are sorted from +x, -x, +y, -y, +z and lastly -z. Each of these would be their own layer in an image editor, for instance, Gimp or Photoshop.

  • Compression: BC1
  • Required Properties:
    • BSLightingShaderProperty > Shader Type: Environment Map
    • BSLightingShaderProperty > Shader Flags 1: SLSF1_Environment_Mapping
    • BSLightingShaderProperty > Shader Flags 2: SLSF2_Glow_Map disabled
  • Appearance Controllers:
    • BSLightingShaderProperty > Environmental Map Scale, 1 is normal intensity, Less than 1 is lower intensity, Greater than 1 is higher intensity.
  • Suffix: _e

Greyscale / metallic cube mask (Slot 6)[edit]

Environment/Cube Mask is a Greyscale Image. Simply a lighting control texture sometimes referred to as a specular map with the purpose to soften or diminish the level of light affecting the mesh reflection. Brightness of individual pixels determines the effect: white will reflect all light and black will reflect no light.

  • Compression: BC1
  • Required Properties:
    • An environment/cube map is required.
    • BSLightingShaderProperty > Shader Type: Environment
    • BSLightingShaderProperty > Shader Flags 1: SLSF1_Environment_Mapping
  • Appearance Controllers:
    • BSLightingShaderProperty > Environmental Map Scale, 1 is normal intensity, less than 1 is lower intensity, greater than 1 is higher intensity,
    • Black is minimum intensity, environment/cube map has no effect in these areas, White is maximum intensity, Intensity increases as shade approaches white
  • Suffix: _m or _em

Subsurface Tint Map (Slot 7)[edit]

This slot is also used for Inner Layer Diffuse and Inner Layer Depth maps in MultiLayer Parallax which will be detailed below. Subsurface tint maps are used for subsurface scattering. This is a rendering effect that simulates the diffusion of light inside a translucent medium. The effect can be seen as an extension on the principles of translucency and is appropriate for realistically simulating a wide range of materials including wax, marble, liquids (like milk), plant leaves, fruit, snow, and most importantly, human skin.

  • Compression: BC1
  • Required Properties:
    • BSLightingShaderProperty > Shader Type: Skin Tint
    • BSLightingShaderProperty > Shader Flags 1: SLSF1_FaceGen_RGB_Tint
  • Appearance Controllers:
    • Brightness of the texture controls translucency while the game defines the underlying color (Set in the race menu.) Typically a very dark greyscale texture. Black is opaque, White is entirely transparent.
  • Suffix: _s

Backlight Map (Slot 8)[edit]

Back lighting fills in the surface opposite a light. This is useful for faking translucency, like showing the bones in a dragon’s wings yet letting light bleed through the skin. The texture can be colored but like glow maps a high emissive value will wash that color out.

  • Compression: BC1
  • Required properties:
    • BSLightingShaderProperty > Shader Flags 2: SLSF2_Back_Lighting
  • Appearance Controller(s):
    • BSLightingShaderProperty > Emissive Multiple
    • Glow intensity increases as emissive multiple increases
    • BSLightingShaderProperty > Emissive Color
  • Suffix: _b or _bl

Slot 9 (Unused)[edit]

Slot09 – Currently Unused.

Shader types[edit]

BSshadertypes01.png

Here you can see the available shader types of a BSLightingShaderProperty. They also need specific shader flags to be set and specific texture maps. Some are essential, others optional. These are all the available Shader Flags for Skyrim:

BSshadersFlagsExport.png

Commonly used in Skyrim are Default shader type (“0”) and Environment Map shader type (“1”). Green shows you those who are essential for exporting a default type mesh successfully, the minimum to be set. Pink are those commonly used additional options for Lighting, environment mapping, or weighting (rigging), glow effects. There are more advanced features like multilayer parallax, but the intention of this short tutorial is, to give people a quick and solid introduction into the rendering settings for meshes used in Skyrim, which are unlike the more recent PBR Systems. You set your mesh shader property type in BSLightingShaderProperties. Note that each NiTriShape can only have one shader type and a small range of optional shader flags and use specific controllers (properties seen below).

BScontrollers01.png

  • The standard for the Glossiness value is 100. It ranged between 0 and 999.
  • Specular Strength ranges from 0 to 10 but 2 would already be very strong, 1 being the default.
  • Refraction Strength ranges from 0 to 1. 1 being absolute transparency.
  • Alpha also does transparency but in a different way.
  • Emissive Colour and Specular Colour are the RGB values that are shining or reflecting when looking straight at the mesh.
  • UV Scale is the scaling size of the UV map. You can right-click on your mesh in the render window and chose textures / UV map and manually edit it, rotate, and scale it.

The most commonly used BSLightingShaderProperties are Default shader type (“0”) and Environment Map shader type (“1”). You set your mesh shader property type in BSLightingShaderProperties. Note that each NiTriShape can only have one shader type and a small range of optional shader flags and use specific controllers(see below). But, if needed, you can simply use multiple NiTriShapes combined on top of each other. As an example, it might make sense to split your mesh into subsections by material (metal, leather) and export each as a different NiTriShape (first sublevel) into the same mesh. Consider a leather armor for instance. I would suggest having an organic leather/cloth part (which usually absorbs light to a high degree and would use the default shader type) and the metal elements (which would reflect light stronger and profit from cube maps used in the environment map shader type).

Default Shader[edit]

  • Name: Default Shader Type (0)
  • used for: Assets with color, height, and specularity.
  • common examples: rocks, clothes, furniture, stones, plants, sometimes metals if specularity is done in a way that can pretend metallic reflections.
  • necessary slots: Slot1) base color/diffuse map AND Slot2) normal map with specularity in alpha channel (optional)
  • necessary flags: those who are marked green above under shader flags, for export; and additionally what you need (vertex paint, specularity for example, if you learned how to apply these)

DefaultShaderExample01.jpg DefaultShaderExample02.png

A House as an example and the shader flags and lighting properties.

DefaultShaderExample03.png DefaultShaderExample04.png

The texture set of a default shader set, consisting of a diffuse and normal map.

Environmental Shader[edit]

  • Name: Environment Map Shader Type (1)
  • used for: Assets with colour, height, and specularity and additional shininess or gloss.
  • common examples: Metals, Chitin, Ore, Armours, Glass, Mirrors, Ice (more stable and consistent with ENBs than parallax)
  • necessary slots: Slot 1) base color/diffuse map AND Slot 2) normal map with specularity in alpha channel (optional) AND environmental/cube map (slot 5) (DTX1, see DDS Texture files for details) AND optional: an environment mask (_m or _em), that sets which areas are reflective (Slot 6)
  • necessary flags: SLSF1_Environment_Mapping, SLSF2_Glow_Map disabled
  • controllers: Environmental Map Scale; 1 is normal intensity, less is lower intensity, greater is higher intensity.

EnvShader1.png

Dwemer armour only with slot 1 and slot 2 (diffuse and normal); Dwemer armour with additional m map in slot 6; Dwemer armour with additional cube map on top of that in slot 5.

EnvShader2.png

Ice: Example of BSLightingshaderproperties controller settings. The ice profits from a detailed normal map with a spec map and the resulting specularity and gloss can be set only by these. An ice cubemap is used in slot 5, but no material map in slot 6.

EnvShader3.png

A typical metal texture set for Skyrim: the rendering will make the diffuse appear much brighter. A lot of detail is being baked into the diffuse. Finally, the sword appears silver-metallic in the game engine.

For how to work on the material map for the roughness and metallic shine, see https://www.youtube.com/watch?v=DWs9rDpA5tQ

Transparency[edit]

Transparency is enabled for each NiTriShape by adding a NiAlphaProperty node.

Blending[edit]

If partial transparency is desired, "Enable Blending" must be checked.

  • For Alpha Blending:
    • Source Blend Mode: Src Alpha
    • Destination Blend Mode: Inv Src Alpha
  • For Additive Blending:
    • Source Blend Mode: One
    • Destination Blend Mode: One
  • For Multiplicative Blending:
    • Source Blend Mode: Zero
    • Destination Blend Mode: Src Color
  • For 2x Multiplicative Blending:
    • Source Blend Mode: Dst Color
    • Destination Blend Mode: Src Color

Alpha Testing[edit]

For Alpha Testing, check "Enable Testing." The Alpha Test Function sets how transparency channel grey values (0 to 255 or black to white) will be compared to the Alpha Test Threshold value to determine the threshold at which pixels with partial transparency should be rendered as completely transparent.

This setting can also be modified at the CK object reference level, allowing a single nif to have variable levels of transparency. This is used most often in Skyrim to create objects with varying levels of decay, like rugs in Nordic Tombs.

Less or Equal: Lighter will be more transparent
Greater or Equal: Darker will be more transparent
Alpha Test Threshold: Value from 0 to 255 (black to white)

Color Blending[edit]

Color Blending Equation

(Source * SourceBlendMode) + (Destination * DestinationBlendMode)

"Source" is the color of the model materials in that pixel before blending. "Destination" is the color of what is behind the model in that same pixel before blending. These two values are modified by the value of the blend mode in that same pixel, then they are added together.

Blend Modes (a.k.a. Blend Factor)

  • One: multiply by one (no modification)
  • Zero: multiply by zero
  • Src Color: multiply by “Source”
  • Inv Src Color: multiply by inverse “Source”
  • Dst Color: multiply by “Destination”
  • Inv Dst Color: multiply by inverse “Destination”
  • Src Alpha: multiply by value of the model’s alpha channel (diffuse and vertex colors) present at that pixel
  • Inv Src Alpha: multiply by inverse value of the model’s alpha channel (diffuse and vertex colors) present at that pixel
  • Dst Alpha: multiply by value of the background model’s alpha channel (diffuse and vertex colors) present at that pixel
  • Inv Dst Alpha: multiply by inverse value of the background model’s alpha channel (diffuse and vertex colors) present at that pixel

Effect Properties[edit]

Effect Properties are set by Bethesda, and the ability to create them without the appropriate tools are limited. However, if you understand the basic structure of nif format meshes and have NifSkope installed, it is easy to copy and paste branches to tweak and reuse the effects that you encounter in the vanilla files. There is quite a variety of usable effects, from animated textures to animated meshes over particle effects and vertex lighting. Many things can be realized with these basic effect types, given the number of controllers to modify them. Note that like with BSShaderProperties, BSEffectProperties are one level below NiTriShape Data and there can only be one of its kind in a NiTriShape, so you might want to use several NiTriShapes in your nif mesh (NiNode skinned rigs or BSFadeNode for statics) if you need several effects. The general workflow would be, similar to how you can exchange shader properties, to:

  • search through meshes for an effect property that supports your vision
  • copy the branch of the effect property
  • remove the branch in the new mesh that is to be replaced
  • paste the branch that you copied there in the NiTriShape
  • tweak the controller settings (numerical values) and set up textures
  • check if you can / have to sanitize the mesh with NifSkope spells
  • check placement and CK implementation, Test it in-game

First Example: Glowing Lantern[edit]

Hello, Travelers, today we’re going to teach you how to make lanterns glow in Skyrim. We originally encountered problems with the way lanterns glow in Skyrim, but one of our members contributed a tutorial on how to make lanterns glow in Skyrim properly.

So, to begin you open the lanterns you want to make glow in NifSkope. Then, you select the paper’s NiTriShape Branch. In that branch, remove BSLightingShaderProperty as well as any other nodes in the branch (Especially anything with alpha layer data in it). Open one of the Dunmer lanterns which we know has a glow effect in another instance of NifSkope. Click on the paper and right-click on BSEffectShaderProperty, highlight Branch, and select Copy Branch. Go back to the lantern you want to change. Select and Right Click on the NiTriShape Branch you removed BSLightingShaderProperty from, and go to block=>paste Block. At this point you have successfully made lanterns glow in Skyrim, however it has the Dunmer texture, so click on the BSEffectShaderProperty we just copied and in the block details window scroll down to “SourceTexture” Double click on this line and put in the path for the texture you want. We now have to set the glow map not to override our color. In the flags change “SLF1Greyscale_to_palette_color” to “SLF1Greyscale_to_paletteAlpha” (This is why it’s important to delete any alpha layer data in step one as we are tricking the mesh in this step.) If you don’t like how bright your lanterns glow in Skyrim, you can adjust that in the settings down near the bottom of BSEffectShaderProperty. The result should look something like this, albeit on whatever mesh you choose.

Other Examples[edit]

  • Rain Clouds (you can also emulate Thunder Storms, Animated Doors etc)

Nifeffects1.png

  • Volcanic Smoke (you can also emulate floating textures like water, lava ...)

Nifeffects2.png Nifeffects3.png

  • Exploding Ice Chunks

Nifeffects4.png

Metadata[edit]

BSXFlags[edit]

The BSXFlags node goes inside of the root node of the nif. In most cases it will be the first one in the root's children. It contains a series of flags that activate different properties of the object in Skyrim. These properties can be accessed and selected by clicking the small flag icon, the total number is the sum of the selected flag values. The list of possible flags is as follows:

Bit/Number Name Description
Bit 0 (1) Animated Necessary for any animation on this asset to play
Bit 1 (2) Havok Enable collision
Bit 2 (4) Ragdoll Used by skeleton nifs
Bit 3 (8) Complex Has more than one bhkCollisionObject
Bit 4 (16) Addon Necessary for any addon node (e.g. candle flame) to appear in game
Bit 5 (32) Editor marker Necessary for an editor marker on this asset to appear in the CK
Bit 6 (64) Dynamic Asset uses Havok physics (affected by gravity, can move around)
Bit 7 (128) Articulated Has a single bhkCollisionObject, or a single kinematic chain
Bit 8 (256) Needs transform updates Never used in vanilla Skyrim or DLCs
Bit 9 (512) External emit Used by assets emitting light
Ambox important.png NOTE: Bit 7 (Articulated) is influenced by a NiSwitchNode, if one is present. Even if multiple branches of the switch node have collision, if a single collision object or kinematic chain is to be displayed at a time, this bit will be set.

This is a cheat sheet of some common BSXFlags values used in vanilla objects:

Number Use Description
130 Statics The player won't be able to interact with the object aside from colliding with it, e.g. Tables, fireplaces, rocks
131 Animated Statics The same as statics, just with animations, e.g. Chests, doors
194 Clutter Havok is activated on these objects, meaning that they have physics applied, e.g. Clutter, weapons, armor ground items

Inventory Marker[edit]

The inventory marker (BSInvMarker) block determines the rotation and zoom of an item when viewed in the inventory. Rotation X, Y and Z specify the clockwise rotation in radians*1000 around that axis, when viewed from the positive side of that axis. The standard view (no rotations) in the inventory is viewing from the positive Y axis. Increasing the zoom value makes the item appear larger in the inventory, decreasing it makes it smaller.

Collision[edit]

Main article: Arcane University:Mesh Collisions

Collision meshes are used to make objects solid in the Creation Engine. A nif can have a single collision mesh, or many. They can be static or moving. The collision settings are also what make the object affected by physics. They determine what parts of an object are interactable. They are typically simpler than the visible meshes, being made up of fewer vertices, since they are invisible and do not need small detail.

See Also[edit]