Markemp / Cryengine-Converter

A c# program to convert Crytek files to Collada (XML) format
https://www.heffaypresents.com/GitHub/
GNU General Public License v2.0
208 stars 52 forks source link

Pass material path as argument #166

Open giniedp opened 6 months ago

giniedp commented 6 months ago

When extracting models for New World, lots of models (and variations) have get their materials overridden by various sources. I need a parameter to pass to the cryengine-converter, to tell which material file it should use, instead of resolving from model file.

For that i already have a patch that i am currently using. Hope it could land in next version

Here is my patch: https://github.com/Markemp/Cryengine-Converter/commit/38c15dbaecf26696d12090fbf37456467bdd3d4a

Markemp commented 4 months ago

Looks good. I've added the code to my features branch and hope to have 1.6 out soonish. This may come in handy for fixing some of the more annoying MWO material bugs too. Thanks!

Markemp commented 4 months ago

Quick questions about passing args for mtl files. I've run into some models (Archeage), where there are multiple material files. I've gone under the assumption that one model file == one material file, but that clearly isn't the case anymore. I've updated the code in 1.6 to output all the Library, Single and Basic material file types (actual material files) to the console so it's easier to see when this happens.

Have you ever run into New World files that use multiple material files?

Would it be ok to accept a comma separated list of mtl file names that match the material files in the models? I'm going to create a dictionary with the node chunk id and the Material, so the proper material file can be referenced.

Ugh, this is going to be a lot of refactoring. But it's more correct, so gotta be done at some point. 😬

image

giniedp commented 4 months ago

I had no file yet that required multiple material files. If a model needs mutliple materials, they are usually embedded inside the .mtl file as SubMaterials and then referenced in the model. I'm fine with comma separated argument list, won't change the workflow in my case.

image image

giniedp commented 4 months ago

or maybe i lied. There are ofc some character models that are consist of multiple model/material pairs. Those are usually coming from .cdf files. In that case i parse the .cdf file, extract model material pairs, run each pair through converter, and assemble all models into one.

Markemp commented 4 months ago

Yah, the cdf files are collections of models and shouldn't be affected by this change. In fact the new material name that includes the material file name as part of it should work better in the case you are assembling a cdf that has duplicate material names from different material files.

I'm just annoyed that 8 years into this project I'm still finding weird edge cases that have been wrong all along but seemed to work good enough. 🤣

I still need to think of a way to help the user figure out whether to provide the material file in the first place. It'll be hard to do bulk extracts where you may or may not need to provide the mtl file when converting.