initial support for daz images

Issue #2058 resolved
Alessandro Padovani created an issue

4.1.0.2131

We never supported daz images, that is, until now we just load a daz image as a simple texture. This works fine if the daz image gets the default parameters, that's the usual for figures and most assets. But daz images provide parameters to adjust gamma and color and tiling. Here we're going to deal with a first implementation.

We can think this as a "DAZ Image" group, that's a simpler version of the "DAZ LIE" group. Of course it is important, for optimization sake, to use a daz image only when the parameters are not at default.

Below there’s the daz image for the test scene. I used the image editor in the diffuse channel.

  • image gamma

Same as gamma in blender, apart that zero in daz studio is the same as one.

if image gamma == 0 then gamma = 1 else gamma = image gamma
  • instance color

Invert is the same as invert color in blender. I'm not sure about scale and offset since these are terms commonly not used for colors so DAZ got a lot of fantasy here, plus there's no documentation. So we can skip these unless someone comes out with some clue.

invert: invert color in blender
scale and offset: no idea how to convert
  • instance tiling

This is important because in daz studio the uber geometry tiling acts per material, so we don't have a per texture tiling, that is, all the textures in a material share the same tiling. If we want textures to have different tilings then we use the daz image editor. This feature is not commonly used for figures, but could be used for environments.

location x = horizontal offset
location y = vertical offset / 2
scale x = 1 / horizontal tiles
scale y = 1 / vertical tiles

Below there’s the implementation for the test scene.

Comments (11)

  1. Alessandro Padovani reporter

    note. minor bug. alpha mode.

    I see that we use “alpha straight” for jpg textures, were it should be “alpha none” as jpg doesn’t get the alpha channel.

  2. Thomas Larsson repo owner

    Implemented in last commit. At least the test file comes in right, and other files that I tested don’t seem to be broken.

    As for the alpha mode, I don’t know. The plugin uses bpy.data.images.load to import the image. If Blender doesn’t detect that this image doesn’t have an alpha channel and sets the alpha mode accordingly, maybe there is a reason for that.

  3. Alessandro Padovani reporter

    Commit 8d43b6f.

    Works fine here, I didn’t test extensively because we have a limited support anyway, and I don’t expect this feature to be used often or in a complicated way by PAs. Eventually we can open other issues if there’s bugs. A few notes though.

    • daz image group. Personally I’d prefer a group to keep the daz image properties together, same as we do LIEs.
    • modulo. I see we always use a modulo before mapping. Modulo is only needed if there’s udims, otherwise it does nothing and can be pruned.
    • alpha none. The blender docs state alpha is ignored if the image format doesn’t support a alpha channel, so it doesn’t matter what we put there. For the sake of clarity and consistency I’d suggest “none“ anyway for jpg.

    https://docs.blender.org/manual/en/latest/editors/image/image_settings.html#bpy-types-image-alpha-mode

    The notes above are not bugs, just possible improvements if it’s not hard to code. Otherwise we can be happy with the current implementation and close as resolved. Let me know.

  4. Thomas Larsson repo owner

    It would be neat to put all related nodes into a group, but it is not so straightforward with the current implementation. The problem is that the plugin only creates one texture node per image, and that node may be used elsewhere in the material. Perhaps one could check if the image is only used once.

  5. Alessandro Padovani reporter

    Yes in daz studio it is possible to use the same texture within multiple daz images with different attributes. But this is the same for LIEs so I don’t get what’s the difference, I mean LIEs have the same problem when used as textures. We can create one group for each daz image same as we do for LIEs. Unless I misunderstand what you mean.

  6. Thomas Larsson repo owner

    Now the image nodes are collected into a node group. It was too complicated to do it when the node tree was generated, so it is done in a postprocessing step afterwards. The grouping is part of the pruning code, so it doesn’t happen if you disable Prune Node Trees in the global setting.

    The node group name always starts with “DIMG”. This is so other tools can recognize this as a daz image group.

    I haven’t done anything about your other issues. I don’t want the alpha type to depend just on the file type, even if that were simple. We know that jpg files never have an alpha channel, but png files can both have and have not alpha, so I want a cleaner way to check if it exists.

  7. Alessandro Padovani reporter

    Commit 9a9d485.

    Thank you for the fix. This wasn’t intended to push you to write complicated code, I was under the impression that this could be treated the same as LIEs. I see that the alpha output is not connected, since daz images don’t provide any alpha operation we can always safely connect the image alpha to the output. So this is probably a bug, let me know.

    p.s. Also the vector input should hide values, that’s usually the way in blender with uv mapping inputs and vector inputs in general, unless they are intended for user values.

  8. Alessandro Padovani reporter

    Commit 3562633.

    Alpha is connected. Again, you need to hide the value for the vector input, for when there’s no texture node connected aka there’s no tiles. Or let me know if there’s any reason not to so we can close as resolved.

  9. Log in to comment