Import a char Blender: Difference between revisions

From PSwiki
Jump to navigation Jump to search
mNo edit summary
 
(20 intermediate revisions by 2 users not shown)
Line 1: Line 1:
As part of the overall port to unreal, all character models are being moved to blender and rerigged with the standard ue4 skeleton and ik setup. This allows for easy retargeting of animation from a blender master animation file onto all characters, significantly streamlining the process of adding new animations in the game. Here I will document the workflow to move characters from obj exports out of 3ds into blender, then prepare them to import into unreal and retarget animations from the master as well as blend multiple animations together.
As part of the overall port to unreal, all character models are being moved to blender and rerigged with the standard ue4 skeleton and ik setup. This allows for easy retargeting of animation from a blender master animation file onto all characters, significantly streamlining the process of adding new animations in the game. Here I will document the workflow to move characters from obj exports out of 3ds into blender, then prepare them to import into unreal and retarget animations from the master as well as blend multiple animations together.


[[File:Planeshift Character Setup (2).png]]
[[File:Planeshift Character Setup (2).png|1200px]]


The first few steps are already completed for all existing character models
The first few steps are already completed for all existing character models.


First, the geometry must be exported from 3dsMax as .fbx to preserve UV mapping for the existing textures. Bones do not transfer properly from 3dsMax to Blender due to the way Blender reverse engineers the .fbx format.
===== Importing the humanoid character template =====


Next, open blender and import the character model. Convert character textures from .dds to .png and assign them within blender, renaming materials and texture names in Blender for consistency. This is where normal maps, spec maps, and alpha information is added, which will transfer to unreal on export.
We store the template in \ueart\characters\Base Animations\UE4_Mannequinn_Template_planeshift.blend


Next the standard ue4 skeleton is brought into the blender file for each character. The skeleton is adjusted to each different geometry and additional bones are added where needed for tails or wings. This needs to be done with all bone layers visible. Once the editing of the skeleton is complete, change the skeleton to pose mode and press Ctrl A, set as rest pose. Next select the mesh, then the skeleton in object mode, and press Ctrl-P, set parent armature with automatic weighting. Also make sure all parts of the mesh have an armature modifier set to the ue4 skeleton.  
1) This template can be exported fully to UE, the settings for export are the same as described below. Importing this will create a Skeleton in UE (ex.: UE4_Mannequinn_Template_planeshift_Skeleton)


The automatic weighting gives a good base but has errors with the module joints and occasionally with the way previous planeshift meshes have been modeled. Clean all wieghting to match along edges of module joints and make sure the weighting is not too strong or dropping off too sharply. This is the step I am on for all characters currently.
2) Go to Retarget Manager, add Current Skeletal Mesh and "Set Up Rig" as Humanoid.


After module joint fixes are done, export the character to .fbx from blender, only exporting selected, using deform bones only and disabling leaf bones.  
3) Save Preview Mesh in the Skeleton.


Load the character asset into unreal and make sure the materials and textures are applying correctly. This should happen automatically on import. Set up the model for retargeting to a humanoid rig in unreal.
4) Only for the humanoid character template which is using ALS, we need to add the virtual bones:


Bring in the blender animations from the master file and also any specific animations from the character file. Next, setup the animation blueprint for the master file and retarget it to each character. This is where animations are triggered and blended together.
Create the Virtual bones for your character '''BEFORE''' retargeting (doing it after will cause issues):


Animations are played at 30FPS, and usually span from 50 to 150 frames. The numbers below are an indication of our current characters, and should not be considered a strict guideline.
{| class="wikitable"
|-
! Source  !! Target  !! VB Name
|-
|hand_l           ||ik_hand_gun ||LHS_ik_hand_gun
|-
|LHS_ik_hand_gun   ||ik_hand_r ||LHS_ik_hand_r
|-
|hand_r           ||ik_hand_gun ||RHS_ik_hand_gun
|-
|RHS_ik_hand_gun   ||ik_hand_l ||RHS_ik_hand_l
|-
|ik_foot_l   ||foot_l ||ik_foot_l_Offset
|-
|ik_foot_l   ||calf_l ||ik_knee_target_l
|-
|ik_foot_r   ||foot_r ||ik_foot_r_Offset
|-
|ik_foot_r   ||calf_r ||ik_knee_target_r
|-
|ik_foot_root   ||foot_l ||foot_target_l
|-
|ik_foot_root   ||foot_r ||foot_target_r
|-
|root           ||root         ||Curves
|}


Here is the official list of needed animations for characters.
===== Get the scale of the Blender scene right =====
We experienced a number of issues with the scale of models in Blender when exported to UE. The problem arise when your root bone in UE shows scaled up 100 times, this seems to mess up sockets attachments.


'''Animations'''
The two setup which are working for us are the following:
Number of frames
''Notes''


'''Walk'''
1) The blender scene is setup with Meters as unit of measure and scale as 1.0. With measurement tool you see the size of your char in meters * 100 , so a human 170 meters (or a horse 370 meters long).
44           
''movement speed must be 1,4 meters / second''


'''Run'''           
[[File:Blender_scale1.jpg]]
30           
''movement speed must be 5,6 meters / second''


'''Sneak'''         
2) The blender scene is setup with Meters as unit of measure and scale as 0.01. With measurement tool you see the size of your char in meters as you expect it to be, so a human 1.7 meters.
50           
''movement speed must be 1 meters / second''


'''Idle'''         
[[File:Blender_scale2.jpg]]
50-60


'''Idlevar'''       
These two cases seems to result in a correctly imported character in UE and sockets will not bug out.
50-60


'''Die'''           
===== Importing a single character =====
50           
''full contact at frame 18-20''


'''Attack'''       
First, the geometry must be exported from 3dsMax as .fbx to preserve UV mapping for the existing textures. Bones do not transfer properly from 3dsMax to Blender due to the way Blender reverse engineers the .fbx format.
30-35         
''full contact at frame 18-20''


'''Attackvar1'''   
Next, open blender and import the character model. Select character textures located in the ueart repository and assign them within blender, renaming materials and texture names in Blender for consistency. This is where normal maps, spec maps, and alpha information is added, which will transfer to unreal on export.
30-35         
''full contact at frame 18-20''


'''Hit'''           
Next, rig the character according to [[Character rigging]]. Once the editing of the mesh is complete, change the skeleton to pose mode and press Ctrl A, set as rest pose. Next select the mesh, then the skeleton in object mode, and press Ctrl-P, set parent armature with automatic weighting. Also make sure all parts of the mesh have an armature modifier set to the ue4 skeleton.
30-35         
''full contact at frame 18-20''


'''Attackidle'''   
The automatic weighting gives a good base but has errors with the module joints and occasionally with the way previous planeshift meshes have been modeled. Clean all weighting to match along edges of module joints and make sure the weighting is not too strong or dropping off too sharply.
30


'''Strafe'''       
For the IK in game to work properly, you need to export the IK bones like ik_foot_r, ik_foot_l . Consider that the option below is excluding all the non deform bones, so the IK must be set as Deform bones. Check that these bones are actually not having any weight on the model.
30           
''movement speed must be 1,35 meters / second''


'''Cast'''         
After module joint fixes are done, export the character to .fbx from blender with the following steps:
60


'''Greet'''         
* Select one mesh at a time (example Torso) and the Armature
80
* Export FBX using "Selected only", "Only deform bones" and disabling "Add Leaf Bones".
* Select Geometry -> Smoothing -> Edge (or you will get an error in UE of "no smoothing group information found")
* Save the file in the /ueart repo under \ueart\characters\Kran\Modules\PSUnreal_Kran_arms.uasset
* Name the file as per our [[Naming Conventions]]


'''Sit down'''     
[[File:blender_export_skeletalmesh2.png]]
55-60


'''Sit idle'''     
[[File:blender_export_skeletalmesh1.png]]
50-60


'''Stand up'''     
* Also if exporting animations uncheck "force start/end keying" so animations will all export to their own length.
55-60


'''Craft'''         
Import the FBX in Unreal, using Load the character asset into unreal and make sure the materials and textures are applying correctly. This should happen automatically on import. Set up the model for retargeting to a humanoid rig in unreal.
70


'''Crafthammer'''   
[[File:blender_export_skeletalmesh3.png]]
70


'''Swim'''         
40


'''Shootbow'''      
'''NOTE:''' Every character uses the same base skeleton, but scaled to fit the model. When you import a skeletal mesh of a character in UE (except the Ylian male which is equal in scale to the template skeleton), the editor will modify the base skeleton (UE4_planeshift_Skeleton_GOOD), and you will see ALL characters gettting an offset on the root bone based on the difference between the template skeleton and the one you are importing. '''<u>DONT save that file</u>'''. The base skeleton should stay at scale 1.
100           
''attack ends at 65, wait till 100 for the arrow to hit''


'''Ride'''         
===== Importing animations =====
100           
''the character sits on the saddle on point 0,0,0''


'''Ridehorse'''     
Bring in the blender animations from the master file and also any specific animations from the character file. Next, setup the animation blueprint for the master file and retarget it to each character. This is where animations are triggered and blended together.
100           
''the character sits on the saddle on point 0,0,0''


Read [[Character Animations]] for specs on frames and animation types needed.




Line 110: Line 105:
An example bipedal character may have:
An example bipedal character may have:
1 head bone
1 head bone
2 bones for the mouth (upper, lower)
1 neck bone
1 ponytail bones


4-6 spine bones
4-6 spine bones
2 bones per each arm
2 bones per each arm
1 bone for each hand (palm)
1 bone for each hand (palm)
2 bone for each hand finger
3 bones for each finger


2 bones per each leg
2 bones per each leg
Line 123: Line 117:
Optional:
Optional:
4 bones for the tail
4 bones for the tail
4 bones for each wing
Various ik bones to help with rigging


Article in progress - to be expanded with more information and step by step images as I go
Article in progress - to be expanded with more information and step by step images as I go

Latest revision as of 20:37, 5 July 2024

As part of the overall port to unreal, all character models are being moved to blender and rerigged with the standard ue4 skeleton and ik setup. This allows for easy retargeting of animation from a blender master animation file onto all characters, significantly streamlining the process of adding new animations in the game. Here I will document the workflow to move characters from obj exports out of 3ds into blender, then prepare them to import into unreal and retarget animations from the master as well as blend multiple animations together.

The first few steps are already completed for all existing character models.

Importing the humanoid character template

We store the template in \ueart\characters\Base Animations\UE4_Mannequinn_Template_planeshift.blend

1) This template can be exported fully to UE, the settings for export are the same as described below. Importing this will create a Skeleton in UE (ex.: UE4_Mannequinn_Template_planeshift_Skeleton)

2) Go to Retarget Manager, add Current Skeletal Mesh and "Set Up Rig" as Humanoid.

3) Save Preview Mesh in the Skeleton.

4) Only for the humanoid character template which is using ALS, we need to add the virtual bones:

Create the Virtual bones for your character BEFORE retargeting (doing it after will cause issues):

Source Target VB Name
hand_l ik_hand_gun LHS_ik_hand_gun
LHS_ik_hand_gun ik_hand_r LHS_ik_hand_r
hand_r ik_hand_gun RHS_ik_hand_gun
RHS_ik_hand_gun ik_hand_l RHS_ik_hand_l
ik_foot_l foot_l ik_foot_l_Offset
ik_foot_l calf_l ik_knee_target_l
ik_foot_r foot_r ik_foot_r_Offset
ik_foot_r calf_r ik_knee_target_r
ik_foot_root foot_l foot_target_l
ik_foot_root foot_r foot_target_r
root root Curves
Get the scale of the Blender scene right

We experienced a number of issues with the scale of models in Blender when exported to UE. The problem arise when your root bone in UE shows scaled up 100 times, this seems to mess up sockets attachments.

The two setup which are working for us are the following:

1) The blender scene is setup with Meters as unit of measure and scale as 1.0. With measurement tool you see the size of your char in meters * 100 , so a human 170 meters (or a horse 370 meters long).

2) The blender scene is setup with Meters as unit of measure and scale as 0.01. With measurement tool you see the size of your char in meters as you expect it to be, so a human 1.7 meters.

These two cases seems to result in a correctly imported character in UE and sockets will not bug out.

Importing a single character

First, the geometry must be exported from 3dsMax as .fbx to preserve UV mapping for the existing textures. Bones do not transfer properly from 3dsMax to Blender due to the way Blender reverse engineers the .fbx format.

Next, open blender and import the character model. Select character textures located in the ueart repository and assign them within blender, renaming materials and texture names in Blender for consistency. This is where normal maps, spec maps, and alpha information is added, which will transfer to unreal on export.

Next, rig the character according to Character rigging. Once the editing of the mesh is complete, change the skeleton to pose mode and press Ctrl A, set as rest pose. Next select the mesh, then the skeleton in object mode, and press Ctrl-P, set parent armature with automatic weighting. Also make sure all parts of the mesh have an armature modifier set to the ue4 skeleton.

The automatic weighting gives a good base but has errors with the module joints and occasionally with the way previous planeshift meshes have been modeled. Clean all weighting to match along edges of module joints and make sure the weighting is not too strong or dropping off too sharply.

For the IK in game to work properly, you need to export the IK bones like ik_foot_r, ik_foot_l . Consider that the option below is excluding all the non deform bones, so the IK must be set as Deform bones. Check that these bones are actually not having any weight on the model.

After module joint fixes are done, export the character to .fbx from blender with the following steps:

  • Select one mesh at a time (example Torso) and the Armature
  • Export FBX using "Selected only", "Only deform bones" and disabling "Add Leaf Bones".
  • Select Geometry -> Smoothing -> Edge (or you will get an error in UE of "no smoothing group information found")
  • Save the file in the /ueart repo under \ueart\characters\Kran\Modules\PSUnreal_Kran_arms.uasset
  • Name the file as per our Naming Conventions

  • Also if exporting animations uncheck "force start/end keying" so animations will all export to their own length.

Import the FBX in Unreal, using Load the character asset into unreal and make sure the materials and textures are applying correctly. This should happen automatically on import. Set up the model for retargeting to a humanoid rig in unreal.


NOTE: Every character uses the same base skeleton, but scaled to fit the model. When you import a skeletal mesh of a character in UE (except the Ylian male which is equal in scale to the template skeleton), the editor will modify the base skeleton (UE4_planeshift_Skeleton_GOOD), and you will see ALL characters gettting an offset on the root bone based on the difference between the template skeleton and the one you are importing. DONT save that file. The base skeleton should stay at scale 1.

Importing animations

Bring in the blender animations from the master file and also any specific animations from the character file. Next, setup the animation blueprint for the master file and retarget it to each character. This is where animations are triggered and blended together.

Read Character Animations for specs on frames and animation types needed.


Number of Bones

An example bipedal character may have: 1 head bone 1 neck bone

4-6 spine bones 2 bones per each arm 1 bone for each hand (palm) 3 bones for each finger

2 bones per each leg 2 bones for each foot

Optional: 4 bones for the tail 4 bones for each wing

Various ik bones to help with rigging

Article in progress - to be expanded with more information and step by step images as I go