Skip to content
Bad Dog edited this page Jul 10, 2024 · 77 revisions

Installation

The latest version of the addon is available under "releases"--find and download "io_scene_nifly.zip". Install like any other Blender addon. Works with V3 and V4 of Blender, but I only do complete testing on V4, so beware.

Upgrading

Shut down Blender completely. Then launch a new window and install the new version like normal. No need to uninstall the old version. Do not import or export anything before upgrading. (If you do that, it attaches to the DLL and there's no way to detach it again. You wanted to know that.)

You may need to close Blender again and re-open before the new version takes. The system will now print the version number to the console on import/export so you can know what you actually got.

Usage

The design philosophy is that everything should just work, with no extra steps. Reasonable defaults are applied if needed. A round trip (import nif -> export nif) should work and result in the same nif you started with. So I've tried to limit switches and options. If you're not sure how things should work, import an interesting nif and see what you got--all the settings you might use as a modder are used by the importer.

Importing models

  • Use the "Nif file with Nifly" option on the import menu.
  • "Use Blender orientation" will scale the nif down to Blender units and orient it so you're facing the front. Handy, not necessary.
  • Shapes will be given a material and shader nodes approximating the definitions in the nif.
  • The nif's root node is represented as a Blender empty object. The nif contents are children of that node. Any other grouping nodes in the nif will also be represented as empties.
  • Handles Skyrim and Fallout nifs. Support for older Fallout games may be sketchy and require some manipulation in nifskope. Report any problems in the issues.
  • Shaders and texture files, collisions and extra data nodes are imported. (No MOPP collisions yet.)
  • Bones will be imported and assembled into an armature. The mesh will be given an armature modifier for that armature. If you select an armature first, then import, the new bones will be added to the existing armature. If you want a full armature, import the skeleton first.
  • Non-humans have their own skeletons. Either don't use the "Rename bones" and "Create bones" options, or import their skeletons first, or use the "Reference skeleton" option to point the importer at the right skeleton.
  • Skyrim-style partitions will be represented as vertex groups and given names as you'd see with nifskope.
  • FO4-style subsegments will be represented as vertex groups and given names that represent the segmentation. Read that section if you're dealing with FO4 segmentation because it's special. Very special.
  • Weapon and armor connect points have special handling.
  • The system can import multiple nif files in a single step, combining them sensibly on the import. Details here.

Options:

  • Create bones--Bones will be added as needed to connect new bones all the way up to the root. Turn this off on the import screen if you're not dealing with a human skeleton.
  • User Blender orientation--Scale the nif down by 10 and rotate 180 to suit Blender's defaults.
  • Rename bones and Rename bones as per NifTools--Renames bones and their vertex groups to conform to Blender's convention for left/right symmetry. Turn this off on the import screen if you need the original names, e.g. if you're working with animations that expect the original name. The second option uses NifTools' naming scheme. (Note these skeletons are not compatible with animation export. Re-parent to NifTools' skeleton before exporting an animation.) If you're using pyNifly's animation support, you can use this option and the animation will work anyway.
  • Import as shape keys--By default, if an object is selected and the object being imported has the same number of vertices, the new object will be imported as a shape key. If you don't want this behavior turn this option off or just deselect everything before import.
  • Apply skin to mesh--If the mesh is skinned, imports it skinned to a Blender armature. If you just want the mesh, turn this off.
  • Create armature from pose position--Create the Blender armature to match the bone pose position in the nif--what you see if you use the "Show Nodes" setting in NifSkope. Turn this OFF if your nif is posed, or if the bone NiNodes are in a hierarchy.
  • Reference skeleton--For use with female and non-human bodies. Enter the filepath of the relevant skeleton here and it will be used to connect up the imported bones and extend them as needed. By default, the human male skeleton is used.

A note on positioning, scale, and transforms

Mostly, you don't have to care. The mesh you design in Blender will show up where you put it. If you skin it to an armature, it will show up relative to the armature where you see it in the view.

Body part meshes are often positioned at the origin in both FO4 and Skyrim. FO4 uses half-precision floating point numbers, and positioning the head where it belongs would make the vertex positions big enough to introduce errors. Putting the head at the origin prevents that. In Skyrim, putting head parts at the origin makes them show up conveniently in CK.

These parts will be positioned at the origin in Blender but the object will be given an offset to put them where you expect. You can see this in the Object Properties panel. The vertices are actually down around the origin, which you can see by looking at the vertex data, local view. Work with them this way and when you export, they'll be skinned and positioned correctly for the game.

This positioning is done with the object transform in Blender, visible on the Object Properties panel.

Some non-human skeletons have human bones at positions that don't match the human position, e.g. Skyrim's draugr and FO4's supermutants. Import these with a reference skeleton, or import the skeleton first and import the nif with it selected, or turn the "Create Bones" option off.

Some nifs have bones in the wrong position, e.g. the facegen nifs for FO4. In NifSkope they show up on their side with parts of the neck pulled out of position. Import these by selecting a good armature and then importing the nif. Get the good armature from the skeleton file or from any nif with the bones in the correct position.

More details here.

Importing tris

  • Use the "Tri file with Nifly" option
  • If you have a Blender object selected and it has the same number of verts as the tri, the morphs will be imported into that object as shape keys. Otherwise, a new object is created.
  • The system will import Bodyslide/Outfit Studio style tri files as well. Morphs that came from such a file will be marked with ">" in the shape key name. Note that you must have one or more objects selected to import these files, because they have no base mesh information. Also the shape names must match, because these files can have tris for more than one shape. If there's no matching shape you'll get a warning and the message will tell you what it's looking for.
  • Some older tris don't have correct UVs, which is fine because the games don't use the UV. They'll throw a warning but import correctly

Shaders

Importing a FO4, Skyrim, or Skyrim SE nif reads the shader and creates corresponding blender shader nodes. Only diffuse, normal, specular, and subsurface textures are used by blender. On export, the Blender shader information is written to the nif as accurately as possible. Any texture slots not used by blender are stashed and written on export. Details on how texture files and shaders are handled can be found here.

Root Node

There's some extra handling for the root node. See here.

Extra Data

ExtraData nodes are imported into Blender "empty" objects. More info here.

Working in Blender

  • A whole nif is loaded under a top-level object in the current collection. You organize the objects however you like in Blender. You can export by selecting individual parts or the top-level root object.

  • If you're working on several body parts, import them by selecting them all at once, or do multiple imports one after another, selecting the skeleton before each import. You'll end up with a single, complete skeleton with all the meshes rigged to it, ready for modeling or posing.

  • If you're working with a head part, import the base mesh then import .tri and chargen .tri with the base mesh selected. All the tris will get loaded onto the one mesh.

  • If you're working with a FO4 head, import the head and then import the "_facebones" head. Delete everything except the "skin_bone" vertex groups, then copy weights from the facebone head to the regular using "Mix" (not "Replace"). You'll get one head with both normal and facebones weights that you can edit and then export in one step.

  • Blender only has partial support for DDS files. If you convert your DDS files to PNG, storing them in the same folders, the importer will use the PNG versions by preference. IceStorm's Texture Toolbox will do mass conversion. Similarly if you're using PNG files in a material you export, the extension will be changed to DDS in the exported nif.

  • Extra data and other additional nodes are represented as additional objects in Blender. To export, you need to select everything that should go into the nif. Collections can be useful for keeping all parts of a nif together.

  • Skinned models bring in whatever part of the skeleton is included in the nif, plus (optionally) bones all the way up to the root. You can hide the armature but don't delete it because you'll need it for export.

  • Humanoid bones are renamed (optionally) to follow Blender's conventions, with '.L' and '.R' marking left- and right-side bones. This makes mirror operations work conveniently. Bones will be named back to the game conventions on export.

  • To change a model to another game, remove the armature modifier, clear the vertex groups, add a modifier for the target game's armature, weight paint, and add game-specific partitions as vertex groups.

  • It's fine to work with quads and without splitting the mesh along UV seams. That's taken care of during export. You may want to control how the triangularization happens though, e.g. for quads along partition boundaries.

  • Nif files only allow 4 weight groups per vertex. If you have more, the lowest weights will get trimmed. If you want to see in Blender exactly what you'll export, use Blender's tool to limit the weight groups per vertex to 4.

  • The nif's normals are imported as custom normals so seams don't show. If you don't need them you can delete them in Object Data -> Geometry Data -> Custom Split Normals. Note that a mesh using model space normals don't have normals on the vertices.

  • When file paths are embedded in a nif (e.g. bodytri paths) the exporter needs to know what path to write. If the files have the correct relative position to the Blender file, the correct filepath will be written. E.g. the Blender file is in C:/model; it uses bodytri C:/Model/meshes/mymodel/themodel.nif; the exported nif will refer to "meshes/mymodel/themodel.tri".

Shape keys

Shape key names tell the exporter what to do with them:

  • If a key starts with an underscore, it will get exported as a separate nif file. So if you have keys named '_0' and '_1', you'll get two files set up for the 0 and 1 weights of Skyrim.
  • Keys that match known expression morphs for the game you're exporting to will be exported to a tri file named after your nif file.
  • Keys that start with ">" will be treated as Bodyslide morphs and that format will be used for the tri. You (probably) won't ever be exporting BS and regular tris from the same mesh. If you do, the BS tris will be given a "_bodyslide.tri" extension.
  • Keys that start with an asterisk '*' will be ignored.
  • Any other keys will be exported to the chargen file.
  • Chargen files are named "(your nif file)chargen.tri" by default. You can choose an extension other than "chargen" on export.

Workflow -- When working with heads, it's convenient to have all the expression and chargen morphs loaded up together so you can fix them all up at once. Then export the head, and you'll automatically get the tri files that go with it. You don't have to worry about whether the tris will match the shape because they are always exported together.

Since the expressions are triggered by the game, it's reasonable to limit that tri to known shape key names. But some tools like RaceMenu will handle morphs that are not known to the game, so any unknown shape key is sent to the chargen file along with the known chargen morphs. If you have any special keys they'll get exported too. That won't harm anything, but if you don't like it, start the name with "*" to keep them from exporting. If the whole scheme gets too cumbersome, duplicate the nif, get rid of the extra shape keys, and export just the ones you want. Rename the "chargen" file after export.

Partitions and Segments

If you need to create partitions or segments, create vertex groups named appropriately--either the "SBP" names or the FO4 subsegment names. Assign faces to the groups and they will be exported. Note every face should be assigned to some such group, if any are assigned. Note vertices at the boundary between partitions will belong to both.

FO4 segments depend on an external .ssf file. If you import a shape, edit it, and export again it will write out that filename into the nif. If you need to use a different file, set the filepath in a "FO4_SEGMENT_FILE" property on the Blender object.

Normals

Blender's handling of normals is very wonky, and getting it to cough up the normals that appear in the Blender view is hard. So mostly the exporter uses the vertex normals, which you can turn on in "Viewport Overlays". If you export multiple nif files from a single mesh (_0 and _1 morphs, for example) the normals will be recalcuated for each morph so they're correct in the file. The exporter will not split a seam to accommodate normals or "sharp" edges. Either split it yourself or give it a small bevel.

But if you have custom split normals--maybe to eliminate a seam where two shapes butt up against each other--the exporter will go with those. You'll get your custom normals in the exported nif (which means they need not be "normal" to the face). It also will not recalculate the normals for the different morphs. This will mostly be right, except if the morph makes a very different shape.

If all this gets too complicated, just duplicate the shapes and export them independently.

Vertex Alphas

Vertex colors painted in Blender are written to the nif as you'd expect, but Blender's handling of vertex alphas sucks. (They know, it just hasn't been prioritized yet.) So if you need to control vertex alpha values, create a color layer called "VERTEX_ALPHA" and color this layer in grayscale. This will be combined with your second color layer to get full RGBA colors. Same on input--you'll find alpha values there if there were any in the nif.

Game-specific summaries

Skyrim

  • _0 and _1 body/armor weights can be represented as shape keys with those names. Make each shape right and a single export will create both files. If your armor has several parts, both weights will be exported even if only some of the parts actually have the key.
  • Expression tris: The system knows what they are, so create shape keys named for each expression ("Aah", for example). A tri file will be exported for them.
  • Chargen tris: The system doesn't know what they are, so any shape keys left over will be exported to a chargen tri. Shape keys starting with ">", "_", or "*" will not be exported to the chargen file.
  • BehaviorGraphExtraData nodes go with the nif, not any particular shape, so they have to be explicitly selected as part of the export.

Skyrim SE

All of LE plus

  • If you have any tri shape keys, you'll get a nif set up to be a head part (with a BSDynamicTriShape).

Fallout 4

  • Tri expression files work like Skyrim, The system will check for FO4's expressions to put in the tri.
  • Chargen tris: The system doesn't know what they are, so any shape keys left over will be exported to a chargen tri. Shape keys starting with ">", "_", or "*" will not be exported to the chargen file.
  • _faceBones files can be exported with the main file in one step. Assign an armature modifier to the regular armature and weight your model; add a modifier for the faceBones armature and do the faceBones weights (you can have both at once). Select the mesh and export. You'll get both files, plus any tri files.
  • BSClothExtraData nodes go with the nif, not any particular shape, so they have to be explicitly selected as part of the export, or select the parent root node EMPTY.

Bodyslide

  • A Bodyslide tri file will be exported with the mesh if it has shape keys starting with ">", which marks a Bodyslide morph. The ">" will be stripped from the export.
  • Bodyslide tri files can contain tris for multiple shapes. If you have multiple meshes selected, they will all go into the nif and all into the tri.
  • The nif will be written with a BODYTRI NiStringExtraData node so the morphs are available in game. There's a flag on the export panel to disable this feature--if you're running the nif through Bodyslide, Bodyslide will write its own extra data.
  • The reference to the tri file stored in the nif is relative to the game root, not to the nif. So you need to export meshes that use bodytris to the same filetree the game uses. E.g. export a feet nif to "C:/mygamestuff/meshes/actors/character/character assets/newfeet.nif". The exporter will write a reference to "actors/character/character assets/newfeet.tri".

Exporting

  • A mesh object must be selected to be exported. If it has an armature modifier, it will be skinned to that armature. Multiple meshes may be selected; they are all exported to the same file. In FO4, it may have two armature modifiers, one for the primary skeleton and one for facebones.
  • If any selected meshes have shape keys with names staring with an underscore (e.g. "_0" or "_1") multiple nif files will be created, one for each such shape key.
  • FO4 ONLY: If any armatures are selected, they'll be checked to see if they are the vanilla FO4 skeleton or a faceBones skeleton. Selected meshes will be exported skinned to all armatures there's a modifier for. A mesh that is skinned to a faceBones armature will get the "_faceBones" suffix to its filename. Both normal and facebones variants are exported at once.
  • Remember to select your target game! The system will try to guess and give you a sensible default if you have an armature, or will default to whatever game you imported the mesh from.
  • If you are exporting to Skyrim SE and your Blender object has expression morphs, then the exporter will create a head part with a BSDynamicTriShape node. Otherwise you get the BSTriShape, and it won't be morphable with that system. (Currently the exporter doesn't check for chargen morphs, which is a missing. Make sure you have at least one expression morph shape key, even if it doesn't do anything. You don't have to use the resulting tri file.)

Options:

  • Target Game--The game to use. If there's an armature, the default will reflect the armature.
  • Rename Bones (per NifTools)--Rename the bones on export back to the game's names.
  • Preserve Bone Hierarchy--Bones will be exported with the root as their parent by default. Set this if you need the bone hierarchy exported.
  • Export BODYTRI Extra Data--Set this to create a reference to the tri file in the exported nif. BodySlide writes this reference itself, so it's not needed if you're creating a nif for BodySlide.
  • Export Pose Position--By default, the mesh is exported in rest position, with bones in rest position. Set this if you want the mesh to be posed in the nif file.
  • Export Modifiers--Exports the mesh with all modifiers applied.

Problems on Export:

  • If a face is in multiple partitions/segments, on export its vertices will be added to a new group called "*MULTIPLE_PARTITIONS*". This can cause a CTD, so fix them. You may need to triangularize faces on the border between partitions, because the triangularization process can confuse the issue.
  • If a face is in no partitions/segments, on export its vertices will be added to a new group called "*NO_PARTITIONS*".
  • If the shape is skinned but some vertices are unweighted, they will be added to a new group called "*UNWEIGHTED_VERTICES*".

Note that Nif files only support scale factors that are the same in every direction. If your model doesn't have uniform scale, the exporter will give you a warning and continue the export by calculating the scaled vert positions and writing them out at their new positions. If this doesn't give good results, apply the transform in Blender before exporting.

Errors

You'll get a notification of problems when they occur, but the details will be in the console window. Open that up anytime you're not sure what's going on.

Other languages

If your computer is set up in a language that doesn't use the Roman character set, there may be problems. Do this:

  • Go to Preferences/Interface/Translation
  • Under "Affect" turn OFF "New Data"

Structure

  • nifly layer: Does the heavy lifting. It's the part of OS/BS that reads and writes nifs and was recently separated out into its own library. All credit goes to Ousnius and the BS team for this part. Any bugs are probably mine.
  • DLL layer: Wraps nifly plus some additional OS code into a DLL that can be called from any program.
  • PyNifly layer: Provides classes and additional code to give a python-friendly interface to the DLL. Allows reading and writing nifs from any python code.
  • Blender addon: Provides an export/import addon for Blender.