- edited description
order materials same as daz (request from Donald for Sagan)
I received a request from Donald who needs to simplify the Sagan importer. It's to sort the materials by name so that the slots aka material list in blender and daz studio would be the same. This way he can address the material by slot/position instead of searching for it by name.
Please note that in blender the materials are global for the whole scene and referred by name, while in daz studio they are local to an object. That’s why blender adds the .001 suffix when there are name doubles. Then the slots in blender are local to an object and referred by number. So for example two different objects each have a "slot 1" which may refer to different or the same material.
To sort by hand in blender we can go in the material panel and use the move arrows to change the material slot. So I guess it should be possible by script too. Below an example with G8F.
note. This may also be related to the "materials by index" option in the global settings. That I don't know what it does apart perhaps being necessary to read miku miku dance files ?
Comments (16)
-
reporter -
Thanks, Alessandro.
The issue is that if the ordering of an object’s material slots differs between Diffeomorphic and Sagan, one cannot simply copy all the materials from the Diffeomorphic object to the Sagan object, with one keystroke. Currently, the only reason why Sagan needs to parse the scene file is in order to calculate the material name. If the slots were ordered identically, I could simplify Sagan by removing all of this parsing.
Previously, I mistakenly suggested that the DAZ Studio material zone names were arranged alphabetically, but I think that may indeed be a coincedence, and they are arranged by index.
For that reason the “Materials By Index” option, which I didn’t know about, seems promising. I’ll investigate that.
-
I checked the “Materials By Index” option in Global Settings, and then imported. It did not affect the order in which the material slots were set up.
-
repo owner I added a button in the advanced > materials section: Sort Materials By Name. Is that enough, or do you need an option to do it automatically when scenes are imported?
-
Hi Thomas,
I think that’s sufficient, but a global option that is persistent would be optimal, I think.
I think what I need is the materials arranged by material zone index, which I think is usually the same as alphabetical order. On second thought, I will just explicitly sort them by name as well, and then they should always match.
Out of curiosity, why does the order in Diffeo come out different from the order in DAZ Studio? Is it not processed as just an array that has an order?
Thanks again for the support.
-
reporter Donald, it can’t be “persistent“ since the user can change the slots of course. Unless for “persistent“ you mean that’s done when loading the scene as Thomas is asking.
-
repo owner Donald, the materials are created in the order that they appear in the duf/dsf files, which is consistent with the material index assignment. DS sorts the materials by name in the surface tab, but that does not reflect the internal material order.
-
reporter Thomas, can you explain please what the “materials by index“ in the global settings exactly does ? I’m not using it myself but as I understand it “index“ in daz would be the same as “slot“ in blender ? That means the materials are identified by “object+slot” instead of “name” ? Is this affecting anything other than importing miku miku dance ?
Materials By Index: Use index rather than name to identify materials. Needed to import MikuMikuDance files correctly.
-
repo owner It was introduced in
#926, to handle multiple materials with the same name. Never seen any other assets which needed it. -
reporter Thank you now I remember. In daz studio it is impossible to assign the same name to two materials. So that is probably a bug in the miku muku dance exporter.
-
Alessandro: By “persistent” I was referring to the setting whether to sort by name, itself, so that the sorting would always be done automatically when the scene is loaded without the user having to do anything. The button that Thomas added is sufficient, but it would be better to not require any user action, once a global option is set and remembered. Thanks for helping to clarify.
-
Thomas: Ah, makes sense to me now. The order in the duf file is arbitrary, but the order returned by the SDK call is alphabetical.
May I then ask for a persistent, global option to sort alphabetically at scene load time? Thanks again.
Edit: I don’t know if it will matter, or if it has mattered, but that would mean that the C++ HD importer will order them alphabetically, differently (potentially) from the duf order.
-
repo owner Implemented in last commit. The setting is called Sort Materials Alphabetically and is located right under Sort Materials By Index. I also improved the description of the latter setting.
-
reporter Commit 4032866 works fine. Will wait for confirmation by Donald to close as resolved.
-
Works perfectly. Thanks to the both of you.
-
reporter - changed status to resolved
- Log in to comment