Editing Arcane University:NIF Data Format
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 3: | Line 3: | ||
== General NIF structure == | == General NIF structure == | ||
− | [ | + | Nifs use BSShaderProperties and BSTextureSets (with [https://wiki.beyondskyrim.org/wiki/Arcane_University:DDS_Data_Format .DDS image] files) to render meshes. When you open a NIF file in [http://www.niftools.org/ 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 NiTriShapes and they can reside under various parent nodes. Visualize it as a tree diagram; there is a hierarchical order, similar to shoulder -> arm -> hand -> finger. A mesh could be sorted differently, but most meshes look like this. There may be slight variations, but the general idea is the same. |
[[File:NifMeshstructure01.png|400px|thumb|right|An example nif block structure.]] | [[File:NifMeshstructure01.png|400px|thumb|right|An example nif block structure.]] | ||
− | + | [[File:NifMeshstructure02.jpg|thumb|right|Use this option in NifSkope if the blocks are not shown in tree format.]] | |
+ | The '''root node''' always has a block ID of 0. It is most commonly a BSFadeNode (static bodies) or a NiNode (skinned rigged meshes) or a BSLeafAnim/tree node (plants). The '''BSXFlags''' block is used to enable different functions such as collision, physics, or animation. The '''bhkCollisionObject''' contains the collision shape and physics settings. 3D Meshes are represented by '''NiTriShape''' blocks. Each NiTriShape has a second sublevel, which contains a '''NiTriShapeData''' block and the '''BSLightingShaderProperty'''. This is where we set up the way the mesh is rendered with shader type and the shader flags and controllers. If you expand BSLightingshaderProperty, you find the third sublevel; the BSShaderTextureSet, which contains your texture slots. Meshes can be rendered in Skyrim according to their BSLightingShaderProperty or the '''BSEffectShaderProperty'''. | ||
− | |||
− | |||
− | |||
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 data (vertices, normals, tangents, etc). |
− | * | + | * 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. |
− | * | + | * BSLightingShaderProperty holds lighting and texture information. |
− | + | * NiAlphaProperty tells the game how to handle transparency in the mesh. | |
− | + | {{note|This is the structure of Skyrim LE nifs. Special Edition nifs are similar. The main difference is that they use BSTriShapes, which are a combination of the NiTriShape and NiTriShapeData explained here. Some of the BSTriShape attributes can not be manipulated in NifSkope, and they are not supported by most import/export tools, so most modders work with LE nifs. Fortunately, most LE nifs work just fine in Skyrim SE.}} | |
− | + | ||
− | + | ||
==Texture Slots== | ==Texture Slots== | ||
− | [ | + | 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 [https://www.youtube.com/watch?v=xPoxqOcUzNQ UV Maps] in Blender or 3D Studio Max. The UV Map is where you take the geometry 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. |
− | + | ||
− | + | Almost all textures used by Skyrim are [[AU:DDS Data Format|DDS]] (Direct Draw Surface) files. | |
− | + | '''The shader will apply light and effects based on 2 things:''' | |
+ | * The BSShaderTextureSet textures. | ||
+ | * Flags set for the BSLightingShaderProperty. Each flag only works with a specific set of textures. | ||
− | {| class="wikitable | + | [[File:TextureSlots03.png]] |
− | + | ||
+ | {| class="wikitable" | ||
+ | ! Number !! Name !! Use !! naming convention | ||
|- | |- | ||
− | + | | SLOT 1 || diffuse map || diffuse (RGB) + transparency (Alpha) || d.dds | |
|- | |- | ||
− | | SLOT | + | | SLOT 2 || normal map || normal (RGB) + greyscale Specular (Alpha) || n.dds |
|- | |- | ||
− | | SLOT | + | | SLOT 3 || glow map || emissive (RGB) / subsurface color (RGB) || sk.dds |
|- | |- | ||
− | | SLOT | + | | SLOT 4 || bump map || greyscale height / parallax (RGB) || g.dds |
|- | |- | ||
− | | SLOT | + | | SLOT 5 || env. map / cube map || environment (mirror) / cube map (RGB) || e.dds |
|- | |- | ||
− | | SLOT | + | | SLOT 6 || material map || environment / reflection mask (RGB) || m.dds / em.dds |
|- | |- | ||
− | | SLOT | + | | SLOT 7 || - map || inner layer diffuse (RGB) + inner layer depth (Alpha) || -.dds |
|- | |- | ||
− | | SLOT | + | | SLOT 8 || sst.m. || subsurface tint outer colour || s.dds |
|- | |- | ||
− | | SLOT | + | | SLOT 9 || - || - || - |
|} | |} | ||
− | + | {{note|NifSkope uses [[wikipedia:zero-based numbering|zero-based numbering]], so the first slot is Slot 0, the normal map slot is Slot 1, etc.}} | |
− | + | ||
− | + | ||
− | + | ||
===Diffuse Map (Slot 1)=== | ===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 | + | ** Use DXT1 if transparency is not needed. |
− | ** Use | + | ** Use DXT3 if only full transparency is needed. |
+ | ** Use DXT5 if the texture needs partial transparency. | ||
* Required properties: | * Required properties: | ||
Line 72: | Line 69: | ||
=== Normal Map (Slot 2) === | === Normal Map (Slot 2) === | ||
− | The normal map | + | 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. The shader 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. |
+ | 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 Normal Map'' | |
− | + | The tangent space normal map’s alpha channel is 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. | |
− | * Compression: Use | + | |
* 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 91: | Line 88: | ||
* 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. | |
Line 101: | Line 98: | ||
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: | + | * Compression: DXT1 |
* Required properties: | * Required properties: | ||
** BSLightingShaderProperty > Shader Type: Glow Shader | ** BSLightingShaderProperty > Shader Type: Glow Shader | ||
Line 121: | Line 118: | ||
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: | 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: | + | * Compression: DXT1 |
* Required Properties: | * Required Properties: | ||
** BSLightingShaderProperty > Shader Flags 1: SLSF1_Parallax | ** BSLightingShaderProperty > Shader Flags 1: SLSF1_Parallax | ||
Line 130: | Line 127: | ||
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: | + | * Compression: DXT1 |
* Required Properties: | * Required Properties: | ||
** BSLightingShaderProperty > Shader Type: Environment Map | ** BSLightingShaderProperty > Shader Type: Environment Map | ||
Line 141: | Line 138: | ||
=== Greyscale / metallic cube mask (Slot 6) === | === 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: | + | * Compression: DXT1 |
* Required Properties: | * Required Properties: | ||
** An environment/cube map is required. | ** An environment/cube map is required. | ||
Line 153: | Line 150: | ||
=== Subsurface Tint Map (Slot 7) === | === 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: | + | * Compression: DXT1 |
* Required Properties: | * Required Properties: | ||
** BSLightingShaderProperty > Shader Type: Skin Tint | ** BSLightingShaderProperty > Shader Type: Skin Tint | ||
Line 163: | Line 160: | ||
=== Backlight Map (Slot 8) === | === 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: | + | * Compression: DXT1 |
* Required properties: | * Required properties: | ||
** BSLightingShaderProperty > Shader Flags 2: SLSF2_Back_Lighting | ** BSLightingShaderProperty > Shader Flags 2: SLSF2_Back_Lighting | ||
Line 175: | Line 172: | ||
Slot09 – Currently Unused. | Slot09 – Currently Unused. | ||
− | == Shader | + | == Shader Types == |
[[File:BSshadertypes01.png]] | [[File:BSshadertypes01.png]] | ||
Line 312: | Line 309: | ||
[[File:nifeffects4.png]] | [[File:nifeffects4.png]] | ||
− | == | + | ==BSXFlags node== |
− | + | 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 depending on the properties that it possesses. Said properties can be accessed and selected by clicking the small flag icon, the total number is the sum of the selected flags. The list of possible flags is as follows: | |
− | The BSXFlags node goes inside of the root node of the nif | + | |
{| class="wikitable" | {| class="wikitable" | ||
! Bit/Number !! Name !! Description | ! Bit/Number !! Name !! Description | ||
Line 324: | Line 320: | ||
| Bit 2 (4) || Ragdoll || Used by skeleton nifs | | Bit 2 (4) || Ragdoll || Used by skeleton nifs | ||
|- | |- | ||
− | | Bit 3 (8) || Complex || Has more than one bhkCollisionObject | + | | Bit 3 (8) || Complex || Has more than one bhkCollisionObject (mutually exclusive with Bit 7: Articulated) |
|- | |- | ||
| Bit 4 (16) || Addon || Necessary for any addon node (e.g. candle flame) to appear in game | | Bit 4 (16) || Addon || Necessary for any addon node (e.g. candle flame) to appear in game | ||
Line 332: | Line 328: | ||
| Bit 6 (64) || Dynamic || Asset uses Havok physics (affected by gravity, can move around) | | Bit 6 (64) || Dynamic || Asset uses Havok physics (affected by gravity, can move around) | ||
|- | |- | ||
− | | Bit 7 (128) || Articulated || Has a single bhkCollisionObject | + | | Bit 7 (128) || Articulated || Has a single bhkCollisionObject (mutually exclusive with Bit 3: Complex) |
|- | |- | ||
| Bit 8 (256) || Needs transform updates || Never used in vanilla Skyrim or DLCs | | Bit 8 (256) || Needs transform updates || Never used in vanilla Skyrim or DLCs | ||
Line 338: | Line 334: | ||
| Bit 9 (512) || External emit || Used by assets emitting light | | Bit 9 (512) || External emit || Used by assets emitting light | ||
|} | |} | ||
− | |||
− | |||
This is a cheat sheet of some common BSXFlags values used in vanilla objects: | This is a cheat sheet of some common BSXFlags values used in vanilla objects: | ||
Line 351: | Line 345: | ||
| 194 || Clutter || Havok is activated on these objects, meaning that they have physics applied, e.g. Clutter, weapons, armor ground items | | 194 || Clutter || Havok is activated on these objects, meaning that they have physics applied, e.g. Clutter, weapons, armor ground items | ||
|} | |} | ||
− | |||
− | |||
− | |||
− | |||
== Collision == | == Collision == | ||
Line 362: | Line 352: | ||
== See Also == | == See Also == | ||
− | * [[AU:Nif Implementation|Nif Implementation]]: Tutorials on making nifs work in Skyrim | + | * [[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 | + | * [[Arcane_University:DDS_Data_Format|DDS Data Format]]: Information on the DDS format, used for textures |
− | + | ||
− | [[Category:Arcane_University | + | [[Category:Arcane_University]] |
[[Category:Data_Format]] | [[Category:Data_Format]] |