Difference between revisions of "Arcane University:NetImmerse Format"
(split texture sets into own page) |
(→Transparency: add notes about assume shadowmask flag and vertex alpha gotcha) |
||
| Line 116: | Line 116: | ||
== Transparency == | == Transparency == | ||
| − | Transparency is enabled for each NiTriShape by adding a NiAlphaProperty node. | + | Transparency is enabled for each NiTriShape by adding a NiAlphaProperty node. Transparency data is taken from the alpha channel of the diffuse, as well as the alpha channel of the vertex colors, if they exist, even if neither the <code>Vertex Colors</code> nor <code>Vertex Alpha</code> shader flags are enabled. Watch out for this! |
=== Blending === | === Blending === | ||
| + | {{Note|float=right|max-width=40%|Sometimes when using alpha blending (maybe always), the mesh will not receive shadows correctly. To remedy this, add the <code>Assume_Shadowmask</code> shader flag.}} | ||
If partial transparency is desired, "Enable Blending" must be checked. | If partial transparency is desired, "Enable Blending" must be checked. | ||
Revision as of 15:03, 30 November 2025
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.
Contents
General NIF 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
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
- Main article: AU:NIF Data Format/Texture Slots
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.
Some slots are reused for multiple different purposes. For example, when a mesh uses the Glow shader, slot 2 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. It is also important to note that these are in nif order. In the CK TextureSet records, the order of the slots is different, but they are named.
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 Slot | Name in Creation Kit | RGB Channel | Alpha Channel | Texture Suffix | Suggested Compression | Suggested creation method |
|---|---|---|---|---|---|---|
| 0 | Diffuse | Diffuse (base color and ambient occlusion) | (optional) transparency map | (no suffix) | BC1 (no Alpha), BC7[a] for RGBA | Base Color and baked AO |
| 1 | Normal/Gloss | Normal map | Grayscale specular map | _n | BC7[a] | RGB normal map. For specular in the alpha channel, invert a roughness map or insert a PBR specularity. Black is zero reflection, white full. |
| 2 | Glow | Glow map / Skin Tint | none | _g / _sk.dds | BC1 | Color glow map or skin tint. |
| 3 | Height | Grayscale height or parallax | none | _p | BC4[b] | Used for height in parallax shader (broken in vanilla Skyrim). |
| 4 | Environment (cubemap) | Cubemap | none | _e | BC1 | Cube projection of environment for simulating reflections. |
| 5 | Environment Mask | Environment mask | none | _m or _em | BC4[b] | Environment mask. Black is no reflection, and white is full intensity reflection (refer to SLOT 4 for environment). |
| 6 | Multilayer | Inner layer diffuse | Inner layer diffuse | _i | BC7[a] | Color map for inner layer of multilayer parallax shader. |
| 7 | Backlight mask | Backlight mask / Subsurface tint / Alternate specular | none | _b or _bl / (none) / _s | BC1 | Primarily for back lighting shader. Also used for subsurface tint of multilayer parallax, and specular when using model space normals. |
- [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.
Shader types
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:
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).
- 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
- 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)
A House as an example and the shader flags and lighting properties.
The texture set of a default shader set, consisting of a diffuse and normal map.
Environmental Shader
- 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.
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.
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.
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
Transparency is enabled for each NiTriShape by adding a NiAlphaProperty node. Transparency data is taken from the alpha channel of the diffuse, as well as the alpha channel of the vertex colors, if they exist, even if neither the Vertex Colors nor Vertex Alpha shader flags are enabled. Watch out for this!
Blending
NOTE: Sometimes when using alpha blending (maybe always), the mesh will not receive shadows correctly. To remedy this, add the Assume_Shadowmask shader flag.
|
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
- 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
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
- Rain Clouds (you can also emulate Thunder Storms, Animated Doors etc)
- Volcanic Smoke (you can also emulate floating textures like water, lava ...)
- Exploding Ice Chunks
Metadata
BSXFlags
The BSXFlags node goes in the Extra Data of the root node of the nif. It contains a bit field 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 list of flags is as follows:
| Bit/Number | Name | Description |
|---|---|---|
| Bit 0 (1) | Animated | Has Gamebryo animation |
| Bit 1 (2) | Havok | Has Havok collision |
| Bit 2 (4) | Ragdoll | Has Havok ragdoll (actor skeleton) |
| Bit 3 (8) | Complex[a] | Has more than one bhkCollisionObject |
| Bit 4 (16) | Addon | Has addon node(s) (e.g. candle flame) |
| Bit 5 (32) | Editor marker | Has editor markers shown in Creation Kit |
| Bit 6 (64) | Dynamic | Has Havok dynamic rigid body physics (affected by gravity, can move around) |
| Bit 7 (128) | Articulated[a] | Has a single bhkCollisionObject, or a single kinematic chain. This 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. |
| Bit 8 (256) | Needs transform updates | Unknown use. Never set in vanilla Skyrim or DLCs |
| Bit 9 (512) | External emit | Has shapes which use external emittance (e.g. glow that is set dynamically, like windows that change glow color based on weather region) |
- [a] - Bits 3 (Complex) and 7 (Articulated) appear to only be used by vanilla Skyrim for grabbing items. Despite this, they are typically set based on their descriptions here for all objects regardless of whether they may be grabbed.
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 objects | Animated objects like doors or chests with single collision objects or single kinematic chains. |
| 11 | Animated objects | Animated objects like doors or chests with multiple collision objects or kinematic chains. |
| 194 | Clutter/Misc | Dynamic Havok is activated on these objects, meaning that they have physics applied, e.g. Clutter, weapons, armor ground items |
Inventory Marker
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
- 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
- Nif Implementation: Tutorials on making nifs work in Skyrim.
- DDS Data Format: Information on the DDS format, used for textures.
- BSLightingShaderProperty Basics explains further about BSLightingShaderProperty node and it's uses. Includes image examples.














