Skip to content

Transferring a costume between CS3 ‐ CS4 ‐ Reverie

eArmada8 edited this page Feb 18, 2024 · 4 revisions

Transferring a costume between CS3 <-> CS4 <-> Reverie

Costume packages (and other models) are not directly transferable between games, as each game has its own unique set of shaders. The .dds and .dae files are compatible, in general, although .inf may need updating and/or the .dae may need a different skeleton. (More on that later.) If you attempt to use a .pkg that is not meant for that game, you may end up with strange coloring, invisible costumes (floating heads), or even game crashes.

WARNING I will use Alisa's VOFAN costume in this tutorial, which some might consider to be NSFW (although I will keep the camera angles tame).

Here is an attempt to use a model from Hajimari no Kiseki (Clouded Leopard) in Trails of Cold Steel IV (NIS America). On the left is with the original shaders from Hajimari, which are not compatible. On the right, I have replaced the shaders with shaders native to CS4.

Automatic shader replacement

The first and easiest step is to replace all the shaders that exist in the game you are transferring a costume to. Often, this is the only step required to move a model from one game to another. For this first tutorial, I am going to reproduce the image above, porting Estelle's towel costume from Hajimari to CS4.

NOTE: Shader replacement in this case means replacing the incompatible shader with an identically-configured shader from the game you plan to use the model in. That means the shader has the exact same hexadecimal code - for example replacing the Hajimari ed8_chr.fx#7D5B6AA14716CB4C48A6EB8A4185E522 with the CS4 ed8_chr.fx#7D5B6AA14716CB4C48A6EB8A4185E522. Despite identical names (denoting configuration), the files themselves are different.

  1. Grab the ED8 Injector.

  2. Go into the assets folder of the game you are modding. In CS4, it is {Cold Steel IV}/data/asset/D3D11. Put aa_inject_model.py, aa_replace_shaders.py, extract_pka.py and unpackpkg.py from the ED8 Injector in the folder, along with your model to fix.

  3. Double-click aa_replace_shaders.py - or, preferably, run python aa_replace_shaders.py so that you can see if there are any errors. For the first question, press Enter and it will default to assets.pka. For the second question, type in the name of the model, in my case, C_CHR081_C02.pkg. You can do this in a single command, python aa_replace_shaders.py assets.pka C_CHR081_C02.pkg as well.

Your package is now compatible! To get it to load in game, you can either make a custom item, or simply replace an existing costume.

  1. Here I am going to replace Estelle's default costume. Run extract_pka.py, use assets.pka, and extract C_CHR081.pkg. (Or run python extract_pka.py assets.pka C_CHR081.pkg)

  2. Replace Estelle's default costume with the towel costume. Double-click aa_inject_model.py or run python aa_inject_model.py C_CHR081_C02 C_CHR081 to replace the model. Now you can see it in game!

Aside: You can use this tool to replace one character with another character. Use t_name.tbl to find the models you need - to swap a character, swap "model", "face" and "default_face".

Material replacement

Many costumes cannot be directly ported from one game to another, due to missing shaders. For example, if you were to try to move Alisa's VOFAN costume (C_CHR001_C60.pkg) from Trails in Reverie to CS3/CS4, you would find some of the shaders utilized, for example ed8_chr.fx#ACB358CD8D951878947284932E71954C, do not exist in the game of interest in that specific configuration. In this case, the material must be replaced.

Here I am going to port my modified Alisa VOFAN costume to CS3.

If you'd like to follow along, here are the textures for this mod: (File 1 dds/pdn, File 2 dds, File 3 dds/pdn) For the costume (C_CHR001_C60) ami_m, set "DiffuseMap2Sampler" to "assetconv_temp/dds_dae/D3D11/chr001_c60_04_conv_blank.dds". For new_uwagi_collada, set "DiffuseMapSampler" to "assetconv_temp/dds_dae/D3D11/chr001_c60_03_conv_white.dds", "Shininess" to 0.5 and "SpecularPower" to 10.0. For "new_uwagi_collada2", "DiffuseMapSampler" to "assetconv_temp/dds_dae/D3D11/chr001_c60_03_conv_white.dds". For the hat (C_EQU503), new_uwagi_collada1, set "DiffuseMapSampler" to "assetconv_temp/dds_dae/D3D11/equ5xx_00_conv.dds" and "Shininess" to 0.296581244468689. For new_uwagi_collada2, set "DiffuseMapSampler" to "assetconv_temp/dds_dae/D3D11/equ5xx_00_conv.dds". Both C_CHR001_C60.pkg and C_EQU503.pkg come from Trails into Reverie and are in assets.pka.

  1. First, perform automatic shader replacement just as above.

You can see that 6 shaders are unavailable in CS3, #5FA9, #8050, #ACB3, #C8CD, #CC6A and #CEA3.

  1. Decompile the patched pkg that you made in step 1. This will contain CS3 shaders, except for #5FA9, #8050, #ACB3, #C8CD, #CC6A and #CEA3 which are still Reverie shaders. These are being utilized by the materials "ami_m", "new_kinzoku_collada" and "white_m".

Materials Database

  1. We will need to replace these materials, but first we will need to find suitable replacements. Download my database of ed8_chr.fx switches here (also available in CSV for those who prefer spreadsheets). To use the database, download DB Browser for SQLite which is free and available in both install and portable format. (DB for ed8_map.fx here / CSV here. Also a combined file with cs1/cs2 shaders included here: DB, CSV.)

*NOTE: You can also use my search tool written in python, see here.

  1. Open ed8_chr_switches.db with DB Browser (Ctrl-O). Go to the Browse Data tab. The shaders should be there, if not, make sure the shaders table is selected in the Table dropdown.

  2. Here I will replace ami_m (I will need to replace all three). Copy the shader hash for ami_m (either works, here I used #ACB3) into the filter box for shader and press Enter. Now you should only see a single shader.

  1. Set the other filters for features you will need. A good start is to set every 1 to one, and leave every 0 blank (unless it must be 0).

  2. Clear the shader (hash) filter. Now it will show some options. Start adjusting the filters until you find something reasonable. (Remember, you will not find the exact shader! Otherwise my automatic script would have found it.)

Below, I've cleared multi_uv (this shader is for the shoulders and arms, and white VOFAN does not use double UV). Scrolling across, I can see that row 13 (#B8BE) is a perfect match except for multi_uv. (Remember, an exact match does not exist.) #B8BE is a good match assuming that it is a skeletal shader! Remember that we need a shader that has both a skinned and unskinned form, just like the metadata.json above. Try to pick from character models C_CHRxxx instead of other models like C_EQUxxx.

  1. Obtain the material. According to the table, I can obtain the material by decompiling C_CHR013_C03.pkg from CS3. (Actually, if you look at row 13, you'll noticed that it is available in C_CHR001_C60 in Reverie! So I actually copied it from skin_m since #B8BE and EA13 {skinned #B8BE} were already replaced in step 1. But if I didn't have that shortcut, I would get the material from C_CHR013_C03.)

  2. Replace the missing material with the donor material.

  3. Repeat steps 4-9 with the missing materials, "new_kinzoku_collada" and "white_m". Now when you compile this costume, it will work in CS3!

Materials Search Tool

You may also use my find_similar_shaders.py (Right-Click, Save As) script to find replacement shaders. You will also need all_shaders.csv (Right-Click, Save As). Place both files in the same folder, and run find_simiar_shaders.py. Type in the name of the shader you want to find, and then the game you want to search for. Here, I will look for the same replacement for ami_m for Alisa, in CS3:

It will create a text file with a report of available shaders and their differences. The results are ranked, with the most similar shaders at the top and the least similar at the bottom.

Original Shader: ed8_chr.fx#CEA3D5287E9B209B5D3A445DC643297C

Restriction: cs3 is not None

Shaders with 2 differences:

ed8_chr.fx#D434B3C5F3FA2C1FAF79CBA7A317C115: (available in C_CHR009_C02.pkg)
MULTI_UV_MULTIPLICATIVE_BLENDING_ENANLED: 0
ALPHA_TESTING_ENABLED: 0

ed8_chr.fx#EA139A7FBBD11BE1CF4EEE7E100A561F: (available in C_CHR013_C03.pkg)
MULTI_UV_MULTIPLICATIVE_BLENDING_ENANLED: 0
MULTI_UV_ENANLED: 0


Shaders with 3 differences:

ed8_chr.fx#12E95E97335BB5E9123101B561012457: (available in C_CHR000_C01.pkg)
NORMAL_MAPPING_ENABLED: 0
MULTI_UV_MULTIPLICATIVE_BLENDING_ENANLED: 0
MULTI_UV_ENANLED: 0

ed8_chr.fx#1CFEF626225ED17ABED7A578095E3549: (available in C_CHR066_C00.pkg)
USE_OUTLINE_COLOR: 1
ALPHA_TESTING_ENABLED: 0
DOUBLE_SIDED: 1

...

The flags listed are the flags that differ between the search query shader and the result shader, with the values of the result shader. You can see that one of the two top ranked is the #EA13 shader we found earlier using the database, and indeed the only difference is the lack of multi UV which we did not need. If we did need multi UV but can sacrifice alpha testing and multiplicative blending, we could use #D434. If we need multiplicative blending but can sacrifice alpha testing and deal with a double-sided shader with outline color, we could use #1CFE. There will never be a perfect match, as discussed above - this is always an exercise in compromise.

Note: Unlike the search above where I stated it did not matter if you use the unskinned or skinned shader, here I recommend specifically using the skinned shader. You will be less likely to choose an unskinned shader with no skinned counterpart this way, by avoiding shaders that have SKINNING_ENABLED: 0

Miscellaneous

You may also need to repair the skeleton, and/or the locators to fully port a model. CS3 Alisa is one such model. If you check the locators list between CS3 Alisa (C_CHR001) and our model (C_CHR001_C60), you will notice that all the locators at the bottom of metadata.json match. If some are missing in the Reverie model, you may need to add them (assuming they exist on the skeleton); luckily we do not have to. However, there are two attach points that are missing from the .inf file, as you can see below.

chr001_c60.inf from Reverie is on the left, and the finished CS3 version is on the right. I copied the missing entries from chr001.inf from CS3 Alisa.