Adding Cutscenes Facial Animations Support: Tutorial&Tool Feb 12, 2015 18:32:07 GMT 10 Yunee, Claire Redfield, and 11 more like this
Post by LegalSoul on Feb 12, 2015 18:32:07 GMT 10
Hello everyone, and welcome to the tutorial about adding facial animation to the RE4 UHD cutscenes and radio transmissions, to make our future mods even better!
First of all I want to thank Son of Persia very very much for all his brilliant tools, tutorials and a lot of extremely useful information! Without his .bin extractor\generator, this thread would have never existed.
You probably have already realised that RE4 UHD modding is pretty hard and twisted, but if you want to have the perfect facial animation support then it's a freaking torture... I warned you
But, that won't stop us, right?
In this tutorial, as an example we'll be adding facial animations in the cutscenes to the custom character's head that replaces Leon's head. But you are able to add them to every cutscene character that you want.
English is not my mother language, so I'll try to write as detailed as I can, for everyone to understand.
Knowledge you need before this tutorial:
Full understanding of Son of Persia's tutorial that can be found here: residentevilmodding.boards.net/thread/2486/re4-model-importer-exporter-toolset
Tools you need:
-Son of Persia's Toolset from the link above.
-my MorphTool from HERE.
-a hex-editor, choose your favourite, or download HxD (yea, unfortunately you need a hex-editor, but only for two very simple simple copy-paste operation, nothing complicated)
For reasons unknown to me, RE4 UHD uses morph targets for the facial animation, which means that we don't have facial bones here. But we have a fixed number of morph targets which are simply ALL possible face poses that a character can do. For example, in Leon's case there are 29 possible face poses, including the default one.
Key Points of the process:
1. Extracting Leon's original head with all faceposes (with all morph targets), from any cutscene.
2. Generating custom head .bin file (I assume that you know how to do this from Son of Persia's tutorial).
3. Making your 29 .obj custom face poses of your character's head.
4. Injecting 29 face poses information into the .bin file of your custom character's head.
5. Copying that one .bin file with injected face animation to ALL CUTSCENES. Yes, for reasons still unknown to me, the game repetitively stores THE SAME HEAD file in EVERY cutscene file. Though, the file paths and the file name are absolutely the same, so you can easily copy\paste the same file to 100 folders in some few minutes.
1. Extracting the original head with all face poses (morph targets or face poses, call it whatever you want).
All the in-engine cutscenes, that we need, are stored in "Evd" folder and their names begin with "r". You can easily extract their contents using Son of Persia's EVD tool (it is situated in the same folder as UDAS tool in his toolset).
Hint: If you want to know what is happening and which characters are present in a particular cutscene you can check the "Movie" folder of the old RE4 2007 port and you will find all prerendered cutscenes with the names just like these .evd files, OR you can download all the cutscenes here in a super-duper low quality for HDD space saving.
For this tutorial let's extract one of the very first cutscenes (the one with the ashley's photo), which is r100s03.evd. The extracting\repacking process is the same as with the .udas files.
After extracting we have the r100s03 folder.
Animated heads models of any character that we may need are always situated in "r100s03\event\model\evxx00". Where xx stands for the character's ID. So, the ammount of "evxx00" folders may vary depending on the amount of characters that are present in the cutscene.
The IDs are almost the same as in .udas files.
Leon's ID: 00
Ada's ID: 02
Krauser's ID: 39
and so on.
Here in this r100s03 cutscene we have only 2 participants: Leon and Ganado, so you can see only two folders: ev0000, ev1000.
As on the screenshot:
We need to replace Leon's head so we go to the "ev0000". Leon's head is "ev0001.bin" file (head name always ends with "01").
Now things are getting interesting.
If you try and extract this ev0001.bin file, using Son of Persia's BIN tools, you will see that it has generated 29 .obj files in addition to the .smd file.
Their names start with "ev0001_morph_00.obj" and end with "ev0001_morph_28.obj", that makes 29 files in total.
These are the first 11 morph targets for example:
You can open them in your favourite 3d application (3dsMax recommended but not really critical) and see that they are Leon's facial expressions.
For example this is how first 5 Leon's face poses look like:
You should also note, that the first .obj file "ev0001_morph_00.obj" is the default neutral face pose, remember that.
2. Generating custom head .bin file.
If you fully understand Son of Persia's tutorial linked above, then you can easily generate a .bin file with your custom head (don't forget about the freaking TPLs)
3. Making your 29 custom face poses of your character's head.
This is the most important part and it can be done using different methods i think, but here's the method that I used.
Right at this point you should decide whether your eyes will be moving or not.
If not, then you just leave them in this mesh and don't move their vertices to leave them static.
But if you want them to move, then you should transfer them to another mesh (you can use the ev0002.bin cause that's where the original eyes are stored) and rig them to the two correspoinding bones. BUT be careful, if you want the eyes to move properly, you need them to be right in the place of the old eyes. This is due to bone envelopes i think. If your custom eyes will be too close or too far or too high or too-low, there WILL be awful problems like falling of the orbits.
Take that same head, from which you've generated custom .bin file.
It MUST be that same head, with THAT SAME vertices amount as the head, that was used to generate the .bin.
Now we need to make 29 face poses.
I advice you to rig this head first, and then just pose it according to those original 29 face poses. Or you can simply move the vertices without any rigs, but that's a nightmare.
IMPORTANT: Don't delete or add vertices!!! Because you need to keep the same vertices order.
So, after this you should have all 29 faces of your character, that have the same face expressions as the original Leon's morph files (the first one is the default neutral pose of your character, remember that).
This is my example of the first 5 face poses:
As I've said before, I've transfered the eyes in the ev0002.bin so there are no eyes here, but if your custom eyes are not right in the place of the original eyes you should leave them in this mesh.
But this is not the end of this step.
Export all 29 faces in SMD format. We need to get .obj files from all those 29 SMD faces, but to have the right vertices order we need to perform the BIN Generate&Extract operaction again.
So you have to run ALL of 29 SMD face poses files through the BIN generator (forget about the texture stuff here, don't worry about the TPLs at this step).
You will get 29 .bin files after generating.
Now you have to run ALL these .bin files through the BIN extractor again. And the extracted .obj files is what we need, not the .smd.
These .objs that we've got after BIN generate\extract operation are final files that we need.
You can move some vertices here in these .objs and make some final corrections (but don't delete ar add any vertices).
The final .objs should look just like the original ones, they will be divided into multiple elements.
Here are some of them from my example:
Actually you can extract that .bin that you've generated in the 2-nd keypoint and take that .obj file for rigging and moving vertices, but as you can notice, there are a lot of doubled, tripled and even quadruple vertices and a lot of elements in that .obj mesh, so it will be very hard to rig it rather than to rig the SMD.
So now we have all 29 custom .obj morph targets with right vertices amount and right vertices order.
4. Injecting 29 face poses information into the .bin file of your custom character's head.
Okay, now let's inject the morph data into the .bin file!
This step has a lot of text and screeenshots, but actually it's pretty simple.
Take my small tool MorphTool.exe and put it in a folder, then copy all 29 face poses in that folder.
Important: rename all 29 files like this: *_xx.obj, Where the * is you custom file name and xx is the incrementing number.
-- -- -- --
---- -- - -
Then run the MorphTool.exe.
Enter "29" cause we have 29 files.
Then enter first file name, in my case it's "krathead_00.obj" and Press Enter.
Now what the tool does is comparing all vertices coordinates of all morph targets files with the default one (with the one that ends with _00.obj), and counts the coordinates difference, because only coordinates differences are stored in .bin file, not the vertices themselves.
Wait a bit cause the tool must scan all vertices coordinates and compare them to the default vertices.
After completing you can see a file created in this folder, named "morphdata.txt". Open it in a text editor (wordpad, for example, or something stronger, but don't use simple notepad cause it's too weak for such big files).
So, right click morphdata.txt and then click Open With, then select Wordpad or any stronger text editor.
Don't worry you don't need to understand these numbers. Just leave it opened like this for a second.
Now open your custom head .bin file in a Hex-editor. I'm using the HxD.
Choose 4 bytes column length in the upper menu for convenience (this is not crucial though).
Press CTRL+END or just go to the end of the file. Note the Offset value. In my case it's 4C1C0:
Now we must convert this offset to little endian:
To do this, first put spaces between every two characters counting from the end like this:
4 C1 C0
Then put a ZERO in the beginning to have the right representation:
04 C1 C0
And then invert the order of the PAIRS of characters like this:
C0 C1 04
This is the offset that we will need.
This is also the position where we will paste the morph data, so we must let the game know this.
Now go to the offset 2C (this is the same for every .bin file).
This is the place where that position must be placed.
Our .bin file without morph data has 00 00 00 00 there which lets the game know that there's no morph data in this .bin file obviously:
So, you need to enter here that little endian offset C0 C1 04, that we've determined earlier. Just enter it from keyboard and it should be like this:
And the last step is to paste the morph data:
Press CTRL+A (select all) in your wordpad with morphdata.txt opened in it,
then press CTRL+C (copy).
And then go to HxD press again CTRL+END in the HxD (go again to the end of the file),
and Press CTRL+V (paste).
The Pasted Data will be in red.
That's all, we have a file with morph data in it.
5. Copying that one .bin file with injected face animation to ALL CUTSCENES.
Extract all cutscenes .evd files where Leon participates.
Rename our custom .bin file to "ev0001.bin".
Now you need to copy this same file with its TPL in every cutscene.
Copy it and replace to all cutscenes:
-- - -- -- --
- - -- - - -
--- -- -- -
AND SO ON...
That's it! We have the cutscenes facial animations now
Extremely Important Texture Dilemma:
If you check the original .tpl files of the of the ev0001.bin, you will notice that they refer to THE SAME textures but in different .yz2 packs from ImagePack folder.
Reasons to that: UNKNOWN...
So, it would be a huuuuge pain to extract and repack all cutscenes yz2 packs. And this is unavoidable if you want a perfect mod.
But you can use a simpler way with a small compromise:
You can just refer all the TPLs to pl00 and pl08 packs. And the game will show the textures from these packs.
TPLs from r100s03, r100s20, r100s30, r100s40, r100s41, r100s43, r101s00, r101s21, r101s30, r106s00, r120s00, r120s01 Must refer to pl00 yz2 pack which is 01000000.
Every other must refer to pl08 pack which is 01000008.
This is an easy solution because you don't need to mess with ALL cutscenes .yz2.
You will be able to watch the cutscenes from the Movie Browser, and also from the game, but there is one condition: you should not wear Special Costumes, and should not buy a tactical vest, cause in other case the game will read the player model from pl09 or something else, but the pl08 or pl00 will be inactive, so the TPLs will fail to read the textures and the textures will be black in the cutscenes.
The same process goes for radio transmissions.
Hint: Leon's animated head that is used in radio transmissions is "SS\eng\ss_term.dat". You will find the .bin file with the morph data after extracting the DAT using Son of Persia's toolz.
Well, that seems to be the end.
Ask any questions if you have them!