Jump to content
opusGlass

Rigging and exporting meshes in Blender 2.7

Recommended Posts

At the request of some users on the AU discord, here is a dump of all the info I've learned about using Blender 2.7 for rigging and exporting rigged meshes. It probably includes a lot of info applicable to working with rigged meshes in general too. I've tried to describe most of my workflow and list the common issues that I've encountered.
I might flesh it out in the future, including screenshots.

 

Disclaimer: This is just what I did, there might have been new updates that make this unnecessary. But I know this works so I'm sticking with it for a while.

 

=Software=
Blender: 2.78c
Niftools: 2.6.0 dev 4 from 7/30/2018 (must be the 2018 file -- a previous 2016 release had same version number!!)
The modified Niftools files attached to this post
     (Note: This contains one fix for an issue during export after importing multiple Nifs, and another issue where unassigned polygons aren't selected after a failed export.)
Nifskope

 

=Install=
1. Install Blender
2. Install NifTools
3. Copy the modified niftool files into the following directory, so they overwrite the originals: %AppData%\Blender Foundation\Blender\2.78\scripts\addons\

 

=First notes=

  • -As a beginner's rule of thumb, your mesh needs to be roughly the same shape (and position) as the vanilla model whose skeleton you're using. With practice you'll learn where you can and can't deviate from the base shape.
  • -You need to work with meshes from Oldrim/Legendary Edition. SPECIAL EDITION MESHES WILL NOT WORK. You can convert your finished mesh to SE format with SSE Nif Optimizer.

 

=Rigging & Partition notes=

  • -To transfer rigging weights from an imported vanilla mesh to a custom mesh, load them both and make sure they're both parented to the same skeleton. Then while in Object mode right click the vanilla mesh, then Shift+ right click the new mesh, then go to Weight Paint mode. At the bottom of the Tools section you will see "Transfer Weights", run that with these options: Vertex Mapping: Nearest Face Interpolated, Source Layers Selection: By Name.
  • -After transferring weights you can adjust them in Weight Paint mode. You need to have the display mode set to Solid to be able to see these values. Then choose a vertex group in the Data tab to see/edit the weighting of that bone.
  • -If you're using Normalize or Auto-Normalize when painting weights, you'll need to first remove all vertices from any Partition vertex groups. Otherwise the normalization will ruin everything. These groups will be called things like SBP_32_BODY. Use the Data tab to Assign them back to the appropriate groups after you're done painting weights. If you don't add them back, the mesh will be exported with a NiSkinInstance instead of a BSDismemberInstance. (Some creatures don't use partitions, and therefore always have a NiSkinInstance. That's fine.) For the creatures I've worked with, there has been at most 2 partitions, so I just make sure to only weight paint on vertices from one partition (selection masking can help here) at a time so I don't accidentally put any in the wrong partition afterwards.
  • -Sometimes those partitions are split up on an imported mesh, into SBP_32_BODY.002 etc. In those cases, combine them using Assign and delete the numbered groups.
  • -If you get an export error about some faces not being assigned to any body part partitions, it will select those faces for you (if you have the correct 2018 versions of everything). Sometimes it may seem like everything is appropriately added to body parts, but there can be issues with the vertices along the edges of neighboring body parts. Every face should belong to exactly one body part. However, if two faces that are part of different body parts share a vertex, that vertex must be assigned to BOTH body parts. This means you can't, for example, select all of the faces in the HEAD body part and then Remove them from the BODY body part, since this will remove all the shared vertices too.
  • -You'll get corrupted rigging if the object's Transform settings are incorrect for that skeleton. You can use Ctrl+A to apply any existing transforms, then go to the Object tab and type in the opposite (negative) of the correct transforms (look at an imported vanilla mesh), apply those, then finally type in the correct transforms to restore it to the correct position with the correct values. Do NOT apply those last correct transforms, just leave them as numbers in the Object tab. If it's supposed to be all 0's, just applying the existing transformations will be enough.

 

=Export notes=

  • -When exporting, be sure to choose Game: Skyrim and Max Partition Bones: 60. I also always check "Flatten Skin" but I don't know if that's actually necessary. Otherwise the default import and export settings have always worked for me.
  • -You can easily run into problems with the settings in the Object tab, Data tab, Material tab, and Texture tab. If you get an error/issue and you don't know what it is, the best approach is to compare all of the settings in those tabs to a vanilla mesh.

 

=Nifskope (post-export) notes=

  • -After export, I recommend splicing the vertex data and rigging data into a vanillla nif that uses the same skeleton. They must have the same string name on the Root node, then you can copy the NiTriShapeData and paste at end, then for the BSDismemberSkinInstance (or NiSkinInstance) copy branch and paste at end. Remember their new node numbers. Then find the NiTriShape you're replacing and enter those numbers into the Data and Skin Instance slots.
  • -You can also run Copy Branch on an entire NiTriShape node after changing the Root name if the vanilla nif didn't have enough NiTriShapes. After pasting at end, go to the root node, increase Num Children by 1, double click the green refresh symbol below it, then expand the list of children. At the end should be a None, change this to the number of your new NiTriShape.
  • -I've also found that the splicing only works correctly if the NiTriShapes are not children of any NiNode other than the 0 root node at the time of copying.
  • -After splicing in your data, you can adjust the BSLightingShaderProperty and its BSShaderTextureSet (I avoid using the BSLightingShaderProperty exported by Blender but do as you will).
  • -BSDismemberSkinInstances will sometimes not have the Part Flags "PF_EDITOR_VISIBLE" and "PF_START_NET_BONSET" which are necessary for rigging in-game. If you are getting bizarre deformations when the mesh animates but they look fine in Nifskope, be sure to check this. Toggle these on all partitions for each BSDismemberSkinInstance inside Nifskope. I haven't been able to set these from Blender.

niftools-2.6.0-dev4-2018-modifications.zip

  • Like 2
  • reaction_title_1 2

Share this post


Link to post
Share on other sites

Some details for people who look into this for the very first time:

1) Installing the Niftools, you have to put them in the blender folder and under user/appsroaming/blenderfoundation/blender/versionnumber(for me 2.79)/scripts/addons.

2) You will activate the Niftools like in the first picture (user settings/ addons/ ). click refresh at the bottom if it doesn't appear.
unknown.png
3) It will show you a message like this when Blender found the Niftools installation. It still works, despite the warning.
unknown.png
4) Those are the export settings at the end:
unknown.png
5) Set the shader flags accordingly, read up on Haydens general export tutorial if you missed it or want to refresh your knowledge.
you can also read in this PDF what the shaders do, I gathered info from some well known tutorials out here.
unknown.png
6) At the right, there is the vertex paint for weight painting.  These are basically representing the skeletons. In the vertex paint mode for weight, red represents stiffness, yellow the middle and green a super light influence that is not much affected by the bones movement. I still have to look into that myself. When looking into vanilla meshes, you will notice that joints and areas next to bones are very red, and the more you get distance, it becomes yellow, then blue and green and fades finally.

unknown.png
 

For the start, it's best to copy the vanilla weight painting and using a similar shape.
On a side note, steam auto-updating blender might be a useful feature, if you don't use a Niftools exporter version that relies on a specific version of Blender, like 2.49b.

I am still new to this, so I might not be precise or have some vague explanations, but I hope you can correct me and we are one step ahead ;-)
Big thank you to Gahmuret and OpusGlass, great people!

  • reaction_title_1 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Special topic: editing weights for rigid protrusions (spikes etc)

When adding objects such as spikes that protrude from the body of a creature/armor, you will usually want those protrusions to be rigid. 
That is, you don't want the spike to bend around as the creature animates. The entire spike should animate together as a single unit. Since only the base of the spike is attached to the creature, when the base of the spike moves, the tip of the spike should move along with it.

Unfortunately, when using the Weight Transfer tool to automatically rig the protrusions, they will often have different weights assigned at different sections of the protrusion, causing it to bend as the creature animates. This must be fixed manually.
badweighting.thumb.png.296a74830a4e3b6c7f58c78e2e410fc9.png


Step 1. Use the Transfer Weight tool (see post above) to transfer weights from the body of the creature to the new protrusions (must be two separate objects in blender). You will probably see that each protrusion has a variety of weights (colors):
step1_TransferWeights.thumb.png.a0458d667b5b0a34c42ee678c4c12d53.png

 

Step 2. Open the spike mesh in Edit mode. Select all vertices for a single spike. If the spikes aren't connected you can do this easily: select one vertex, then hold Ctrl and hit Numpad+ a few times.
step2_SelectVertices.thumb.png.c55c59d11a72266f343dc514c282ab39.png

 

Step 3. Open the spike mesh in Weight Paint mode. Enable the option for Vertex Selection Masking. You should see yellow dots on the object you selected, and black dots everywhere else.

 

Step 4. Using the Vertex Groups section found in the Data tab, find all bones that are effecting this protrusion (any color other than the darkest blue, anywhere on the spike). I suggest using the arrow buttons to organize them so that they are all next to each other in the list.

 

Step 5. For one bone, set the weight of all selected vertices. You can type any weight into the area where it says "Weight:", then click Assign. But how do you know what number to type? This takes some trial and error:
     5a. Look at the area where the spike meets the creature's skin. The color found here is the color you want. There may be some small range of colors in the area where the two meet, if so just choose an average color for this area. (If there is a wider range of colors this technique might result in some "sliding" when animated -- see the Sliding Fix below.)
     5b. Give a guess for the number value of this color (Blue = 0, Teal = 0.25, Green = 0.5, Yellow = 0.75, Red = 1.0). Assign that value while watching the edge of the spike closely.
     5c. If your guess was wrong (the color at the edge between spike and skin changes), hover your mouse over the render window and hit Ctrl+Z to undo the change. Type another number and try again. Repeat until you find an optimal weight.
step3-5_EditWeights.thumb.png.96a72835e27914ef1437c5bb8abef5ed.png

After a successful Step 5, the spike's weight should blend perfectly where it connects to the skin, then maintain that exact color for the length of the spike:
step5_successful.png.8d8351729f22ff9830c13c43379e89cb.png
(To get this view, I'm merging the two meshes with Ctrl+J then viewing in weight mode. Then undo the merge with Ctrl+Z.)

 

Step 6. When you're satisfied that the weighting for that bone on this spike is good, proceed to the next bone that is effecting this spike and repeat Step 5.
step6_NextBone.thumb.png.b47993a91064b97ec75ac689a49f62af.png

 

Step 7. When this spike is appropriately rigged to ALL bones that effect it, choose another spike and repeat Steps 2-6.

The final result should look like this:
before_after.thumb.png.e104e6aa3f27602d99b63e478fc5a30c.png


 

 

Sliding Fix
Now, as mentioned in Step 5a, there will sometimes be a "sliding" effect if you completely rigidify a spike that had a wide range of bone weights at its base. The spike will stay solid while the flexible skin underneath it moves in various directions, giving the appearance that the spike is not attached to the skin.

In these cases, you may want to leave the vertices near the skin with their initial weights from the Weight Transfer tool, and only edit the weights for vertices that don't directly touch the skin.

In Step 2, just only select the vertices that are far from the surface of the skin, then proceed like normal. Here you can see that I only selected the 7 farthest vertices of this spike and left the remaining vertices untouched:
sliding_fix.thumb.png.18323a8852f02e3062d8c22643d0ea81.png

 

 

 

That's it! Once you've edited all of your protrusions, your model should be ready for export! :)

goodweighting.thumb.png.f63a9c9cb0f75ef0aa3e5b726c9782c2.png

 

 

  • reaction_title_1 1

Share this post


Link to post
Share on other sites

Thanks! I've been wanting to be able to use Blender for rigging so I don't need to rely on a student version of Max. Though I'm having a problem, my mesh exports without errors fine, but I don't see any BSDismemberInstance. 

Edited by IAmTheRedd

Share this post


Link to post
Share on other sites

That was one part I wasn't sure about.  The way I'm doing it was clicking my mesh, then the skeleton or bones of the original and Ctrl+P, I'm not too experienced with skeletons and such so I'm not sure if that's what you ment. But doing that way leads to no Dismemberment in the .nif for me.

Share this post


Link to post
Share on other sites

The goat mesh(my mesh uses it's skeleton)uses a NiSkinInstance, though that still wasn't showing. The mesh seems to be a branch and there are weights.

Share this post


Link to post
Share on other sites
On 06/03/2018 at 1:55 AM, opusGlass said:

I've only worked with models with up to 2 partitions, but my workflow is

What does partitions mean?
One partition vertex group = one bone right?
Are you saying that you worked on creature with two bones?
Some kind of worm maybe?

opusGlass Thank you alot for the tuto and for the files.

Edited by Madao

Share this post


Link to post
Share on other sites
2 hours ago, Madao said:

What does partitions mean?
One partition vertex group = one bone right?

If a mesh has a BSDismemberSkinInstance, it has partitions; if it has an NiSkinInstance, it does not. Either of these will contain vertex groups corresponding to the bones of the rig. But if it has partitions, those will also be treated as vertex groups in Blender. Typically, every face of your mesh is assigned to exactly one partition, with a weight of 1. This is in addition to being assigned to some number of bones with varying weights (which typically add up to 1). 

The partitions are usually used for hiding the underlying skin when armor is worn over that body part. I think they are maybe used for decapitation too. In any case, to make sure everything runs smoothly I just keep it consistent with the creature whose skeleton I'm using.

  • reaction_title_1 1
  • Thanks 1

Share this post


Link to post
Share on other sites

A new version of the blender Nif plugin was released in 2018, despite the version number remaining the same. As a result, my patch files have been updated to a 2018 version. Make sure both are up-to-date!

Additionally, I've now fixed an error related to Unassigned Body Parts, and updated that section of the instructions with new info.

  • reaction_title_1 1

Share this post


Link to post
Share on other sites

Sorry if this was alredy asked. But I don't see it. What about Blender 2.79b? Is this method would work with it? And what about niftools? I need 2018 realise with it? Sorry for bad english.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×