make material set ?

Issue #947 resolved
Alessandro Padovani created an issue

daz studio 4.15.0.30, blender 3.1.2, diffeomorphic 1.6.1.0945

This is related to #945. The issue is that in blender there's not a "material set" concept, so there's no way to store all the materials of an object into a "object palette" to reuse later. This is not possible even with the new asset browser.

To help with this issue we could use a placeholder for the object materials, that could be for example a cone primitive. This "palette" can then be saved by the user and loaded when needed to use the "copy material" tool. So below there's the proposed new tool that could be added to the materials panel.

make material set:

  1. create a cone primitive, that will be our palette
  2. for the selected object assign the object materials to the cone, one material per face
  3. mark the cone as asset so it's ready for the asset browser

Below an example of the idea where I assigned some g8f materials to a cone palette. Please note that it is not necessary to create new materials for the palette, just assign the object materials to the cone faces in edit mode.

note. As a side note I noticed that when we import a figure the materials get a number, for example "Torso" in daz is renamed as "Torso-1" in blender. I wonder if this is necessary for some reason, otherwise avoiding the extra numbers would be "better looking" as material names. I mean, if there are conflicts with names blender already renames as .001 etc so we don't need extra care for that, if that's the reason.

Comments (19)

  1. Alessandro Padovani reporter

    It's to work with the “copy materials“ tool that requires an object. Otherwise you have to add an option to the tool. And it provides a visual feedback that may be useful anyway.

  2. Thomas Larsson repo owner

    Implemented in last commit. I put it in the advanced materials panel, and moved some other buttons there too, since I rarely use them.

    As for the material names, that’s how the materials are stored in the duf file. It typically contains a material library, and a scene with materials that refer to materials in the library. So Torso is the name of the material in the library and Torso-1 the material in the scene. Sometimes there are several materials with the same base name, e.g. Eyemoisture (library, body), Eyemoisture-1 (library, lashes), Eyemoisture-2 (scene, body), Eyemoisture-3(scene, lashes). I could try to use the library names instead, but not today because that change could break things.

  3. Alessandro Padovani reporter

    Commit 5cdf210 works great. It may be worth to add a couple notes though since material management in blender is not so easy and may be confusing at first. May be these notes could be useful in the docs too.

    palette shape. As for the palette shape I’d go for a 1 meter size rather than 2 meters. Then since you removed the cone base I also thought at first of flatting it to a disk, but on a second thought the cone is better when you place the palette with the asset browser, to avoid precision artifacts with close geometry.

    unique materials. It may not be obvious that in blender all the materials in the scene are shared by name. This means that we can reuse materials across objects that’s useful, we change the material and all the objects in the scene are affected. But it also means that if we want a material “unique” for an object we have to make it so. When we create a palette the materials are copied from the object, if we want to make multiple palettes in the same scene, for example to edit and then save in the asset library, then we have to make them “unique“. This is done with “make single user“.

    Please pay attention to select the “materials“ option so to only duplicate the materials and don’t duplicate the images that would take memory (especially vram) for nothing.

    absolute/relative textures. Again this may not be obvious at first. When we move files, that’s needed for example to manage projects or to save files to the asset library, we need to pay attention to the textures file path. The risk is that when we move the file blender can’t find the textures anymore resulting in a pink rendering color. We can make a local copy of the textures and use a relative path. But textures take much space on disk, so it makes sense to just reuse the daz library, that’s also the default behavior of the plugin.

    So, if you use the textures in the daz library be sure to use absolute paths before moving the file around. This is done with “make paths absolute“.

    cleanup after yourself. When dealing with material palettes, especially if you use much of them, it is easy to leave leftovers around. Remember that every palette that you append from a blend file or load from the asset browser, makes a new instance. So when you’re done with palettes and you don’t need them anymore just delete them from the scene. Then blender deletes unused data blocks on exit, but just to be sure you can force the cleanup with the “cleanup“ menu.

    keep things under control. Again managing complex scenes it may be easy to lose control on what you’re doing. So it comes handy a little addon that’s included in blender where you can keep track of exactly how many data blocks your scene gets. That’s the “blend info“ addon. As for material palettes it is especially important to keep an eye to the number of images.

  4. Alessandro Padovani reporter

    As for the material names, it is important that it works with “import daz materials“. I don’t know the technical side but daz uses material names relative to the object while blender uses material names global to the scene. I mean for example if we load multiple figures then there will be “duplicates“ anyway that blender handles with .001 suffixes.

    But may be the internal numbered daz names are necessary for “import daz materials“ to work fine. Please let me know.

  5. Thomas Larsson repo owner

    The improvements have been implemented in the last commit.

    As for the material names, I don’t know what will happen if we strip the final digits when the Blender material is created. Perhaps nothing, but I’m not ready to take the time to investigate that atm.

  6. Alessandro Padovani reporter

    Commit 5588ffd works great.

    For palettes to work we need the material names to match. I mean if we save palettes then change the names later then all the saved palettes will not work anymore. So it is important to look at this and decide what to do. I can do some tests with “import daz materials“ if you can change the names.

    Or we can keep the names as they are so this is settled. Let me know.

  7. Midnight Arrow

    Blender cannot have multiple datablocks with the same name so trying to use this with more than one figure in a scene would fail anyway. It’d need to be done via material indices, or else it’d need to use custom string properties rather than direct material names.

  8. Alessandro Padovani reporter

    No the “copy material“ tool ignores .001 suffixes of course. So only the base name is considered. Then there’s the option for indices too.

    But, on a second thought, keeping the daz names with numbers as they are now will make the new palettes compatible with the old projects. It will also help if we merge meshes since eyemoisture-1 -2 -3 will keep the names. So I’m marking as resolved as it is. We don’t change the names.

  9. Thomas Larsson repo owner
    • changed status to open

    This tool has been renamed Make Palette and now generates a square mesh, with separate slots for each material. Useful for previewing materials where Blender's builtin previewer fails, i.e. if the uvs are assigned with uvmap or attribute nodes. Here are some examples. palette.png

  10. Alessandro Padovani reporter

    Personally I don’t like the new palette shape. I mean we already have the material preview panel in blender to look deep at one material. While the cone palette just gives a hint and there’s the material name.

    Please Thomas let me know if we can have options for the palette shape as cone/plane. Or I’ll mark as resolved anyway since this is minor.

    edit. Or we could have a cylinder palette like this. I used “uv > lightmap pack” to map each face of the cylinder to the full uv space.

    edit. To expand the uv space per face we could also do with the cone shape that gets more texture information this way.

  11. Midnight Arrow

    @ Alessando

    The “Reset” operator below the the lightmap pack option will also make faces use the full UV space, and it’s less complicated.

  12. Log in to comment