better layered images (LIE)

Issue #780 resolved
Alessandro Padovani created an issue

daz studio 4.15.0.30, blender 2.93.6, diffeomorphic 1.6.1.0718 commit 0eae73e

This is related to #778. I'll try to help provide a better support for layered images, that's currently limited thus causing a number of assets not working fine. I'll take as a first example the realistic tears in #778. Test scene tears-dry.duf.

https://www.daz3d.com/realistic-tears-for-genesis-8-and-genesis-3

Let's open the test scene. Now we look at the LIE for the cutout opacity of the face material, in the tears shell. We see that two images are mixed with an additive blend. This is saved in the duf as a "map" list. Below are the LIE and the duf. Please note that the top layer in the LIE is the last in the duf list.

So to translate this for blender the correct node setup is below. I used the add node in blender for the additive blend in the LIE. Please note that the last image in the LIE stack gets nothing to blend to. Also the gamma of the images is 1.0 this means the gamma is not changed and the images are srgb.

Below the test scene rendered in iray, then cycles as it is now, then cycles fixed as explained above.

Thomas, by experimenting with the LIE and looking at the relative duf file you should be able to get most options done in blender. Please let me know if you need help with anything I'll try to follow. Then whenever we meet new bugs I'll update this discussion.

As a first start we may provide support for the blend modes, then we may go on with the other options. The blend modes in the LIE are below.

  • Alpha Channel: mixrgb node with mix operator in blender, with the alpha channel as fac
  • Multiplicative: mixrgb with multiply operator in blender
  • Additive: mixrgb with add operator in blender
  • Subtractive: mixrgb with subtract operator in blender

I'm also providing a little start lie-test.duf with its net-1.png texture, though it’s very simple this is actually converted bad.

Comments (25)

  1. Thomas Larsson repo owner

    The code for image maps is very old, and apparently all layers without a texture were ignored completely. The test file is now imported correctly, but I will check other files when I get home.

  2. Alessandro Padovani reporter

    Yep I’m not expecting this to be fixed fast there are a number of options in the LIE to watch for. Please note that we got pale LIEs because we used non-color instead of srgb. The LIE is an image editor thus deals with srgb images, unless the gamma is different than one.

  3. Alessandro Padovani reporter

    As for commit f9fd6dc the yellow color in the LIE in lie-test.duf should be gamma corrected in blender, since it’s srgb. There’s (255,255,128) in the LIE and I get (1.0,1.0,0.502) in blender, while it should be about (1.0,1.0,0.216). See #19. Also see point 3 in #349 “linear and srgb colors“ to get how to convert different color spaces in the duf file.

  4. Thomas Larsson repo owner

    The layered image code has been cleaned up. Perhaps it doesn’t work in all cases yet, but the new is a better foundation to build on.

  5. Alessandro Padovani reporter

    As for commit 945c7c7 to me it doesn’t seem to work fine, unless I miss something.

    First in the tears-dry example the LIE uses non-color images while they should be srgb in my opinion because the LIE handles srgb images and produces a srgb output. Also there’s a strange way to handle the influence via a mix node, when it should be a multiply in my opinion, and the fac channels shouldn’t be used apart for the alpha channel blend. See my setup above.

    As a side effect the influence can’t work this way even if we set it at 10 we get nothing.

    Below there’s cycles as for commit 945c7c7. We can see that the tears are pale and the smudge layer is barely visible, compared to iray and my setup above. And the influence doesn’t work.

  6. Alessandro Padovani reporter

    To better explain things, I did a new example lie-2.duf. Below it is the setup, the fac channel in blender can be used for the opacity channel in the LIE.

    Then below the rendering, first iray, then cycles as it is now, then cycles fixed with the setup above. I am not sure why the alpha channel for image 0 gets much more visible than iray, perhaps fac = opacity ** 2 but it doesn’t seem so for the other layers, other than that the setup works fine.

  7. Thomas Larsson repo owner

    The latest commit imports your last example rather well, but the little square appears to be too yellow compared to your last image. That would be fixed by changing the final mixrgb node back to mix.

    I also make explicit links from the Alpha outputs to the Fac inputs. This is perhaps unnecessary, especially for the jpg images, but I don’t think it hurts. The mix node has a setting called use_alpha, which probably means that it will automatically use the alpha channel.

  8. Thomas Larsson repo owner

    Ah, now I see what you were doing. Multiply with influence, not with the first node. Now your test file comes in correctly, and the tear intensity can be changed.

  9. Thomas Larsson repo owner

    Multiplication mixing does not work well outside shells. A common case is to add bruises or dust as a layered image, where the first texture is the base texture. In that case influence = 0 must mean that output is the first texture.

  10. Alessandro Padovani reporter

    Ok now I get it, you want influence = 0 to show the bottom layer and otherwise mix all the other layers together, that makes sense. But this way you’re limited to influence from 0 to 1, that is, influence = 10 will be the same as influence = 1. So you can’t for example “stress“ a makeup.

    What about the setup below that does what you want plus allows for influence > 1. I use a multiply that does influence * lie, then mix with the bottom layer.

  11. Thomas Larsson repo owner

    No, that only works if intensity = 0 or 1, but not for other values. Here is intensity = 10.

    But it is not super important that you can increase it above 1. The main thing for me is that layers can be turned off.

  12. Alessandro Padovani reporter

    Ok I get it. Anyway to stress a makeup we can always use the influence of the shell itself so you’re right this doesn't really matter. As for commit bb731d3 the LIE images for the tears-dry scene are non-color. In my opinion they should be srgb for the LIE but if you did non-color on purpose I can live with that.

    Let me know so I’ll mark as resolved.

  13. Thomas Larsson repo owner

    The color space is determined by the node that uses the texture. The tears-dry layered textures are used for bump strength (pruned), glossy roughness, and cutout opacity, and all of these expect a linear texture. In the last commit I combine the textures in srgb, and add a gamma 2.2 at the end to convert to linear colors if needed.

  14. Thomas Larsson repo owner

    There is also another issue. The shell adds a texture to the bump strength, but no bump node is generated. Will look into that.

  15. Alessandro Padovani reporter

    Commit 7a0e6dc works great, thank you Thomas for the super fast and nice work on this. Marking as resolved for now and reopen if we meet some bugs.

  16. Alessandro Padovani reporter

    Thomas, there’s a bug in the final conversion from srgb to linear. The gamma node needs to be 1/2.2 = 0.455 because it’s a reversed conversion we need to do. Below an example with the essential makeup in #748, before and after the fix.

  17. Log in to comment