nasty displacement bugs (and fixes)

Issue #924 resolved
Alessandro Padovani created an issue

daz studio 4.15.0.30, blender 3.1.0, diffeomorphic 1.6.1.0912

I never use displacement myself since I'm more for base resolution figures for animation. Also displacement is usually baked into multires with HD figures. But looking at an old issue #251 I noticed a series of nasty bugs that we're going to fix here.

1. The displacement input and output for shells has to be vector, not scalar. Otherwise the displacement will not work.

2. For the same reason we can't use a scalar multiply for the shell influence, we have to use a vector scale instead.

3. The material settings must use "displacement only", since in iray the bump does not contribute to displacement.

4. In iray there's a subd displacement level that's independent from the general catmark subdivision, this is neccessary to further tessellate the geometry for the displacement map. In blender we can add a simple subdivision to get the same effect. Please note that in blender the simple subdivision will cumulate with the catmull subdivision so we need to subtract.

# we add a simple subdivision to match the iray displacement subdivision
if iray subd displacement > iray render subd
    simple subd viewport = 0
    simple subd render = iray subd displacement - iray render subd

5. Finally below the test scene ngv8.duf that's g8f with ngv8 as for #251. Before and after the fix. Please note that eevee ignores displacement so this works for cycles only.

Comments (7)

  1. Alessandro Padovani reporter

    As a side note in #251 the bump in eevee is not wrong, it is the same as iray if we compare with an iray render. Then the bump in cycles may appear smoother if we use the principled option because cycles treats sss differently than eevee, so the smoother bump is a sss effect.

  2. Alessandro Padovani reporter

    note. important.

    Please note that subd displacement in daz studio is per surface. While subdivision in blender is per object. We may scan all the surfaces in the daz object and use the highest value to get the simple subdivision in blender. Also if the subd displacement is in a geograft then we have to transfer the simple subdivision to the figure when we merge geografts.

    Or as forfait we may set simple subdivision = 1 if there's any subd displacement in daz studio. Since we can't match iray per surface anyway.

    Or we may use the adaptive subdivision in blender. But it's marked as experimental and it seems to take a lot of ram in my system to compute, so I don't know if this is a good idea.

    https://docs.blender.org/manual/en/latest/render/cycles/object_settings/adaptive_subdiv.html

  3. Thomas Larsson repo owner

    Most of the issues have been dealt with now. The thing that hasn’t been addressed is using vector scale for influence, because I cannot find it; I can only find vector rotate and vector transform in Blender 3.1. So I used a vector math node instead.

    I also noticed that the incoming displacement socket is not connected to anything, which isn’t good if you stack several shells on top of each other. Perhaps one can use a multiply-add node for the influence.

    The extra subsurf modifier is added to the main mesh after geografts are merged.

  4. Alessandro Padovani reporter

    Thank you Thomas for looking at this. That was fast.

    As for commit 9e9ca88 I get an error when I try the bsdf option with the test scene. The principled option works fine. The scale operator is in the vector math node same as multiply.

    I agree that the incoming displacement should be added for stacked shells. One possible setup is below.

  5. Alessandro Padovani reporter

    NOTE. IMPORTANT.

    On a second thought each shell in daz studio gets its own geometry layer. So displacements are not added but “mixed”. And this also involves the shell offset that should be added to the shell displacement. But this will not work fine on the shell borders in blender. This is a little over my head since I'm basic at math, but for sure it's not a simple addition of displacements.

    We may also ignore the stacked shells and just consider the last displacement, so leaving the incoming displacement alone as it is now. That is, there will be displacement only for the upper shell and bumps for the lower shells. This seems fair enough since we ignore the shell geometry.

    Then a more complete and precise implementation may come from #862. Though for the usual case the actual implementation is fine and more optimized.

  6. Thomas Larsson repo owner

    Now scale is used for displacement influence.

    If the shell doesn’t use displacement, the displacement input and output are connected. So we can only have one shell with displacement, but it doesn’t have to be the last one. That several shells would create separate displacement maps seems very unusual, so I think this is good enough.

    I cannot reproduce your error, neither at home nor at work. A unicode decode error typically means that some string contains an illegal character; perhaps you have accidentally changed the file name of some texture.

  7. Alessandro Padovani reporter

    Commit 0559b5c works fine.

    I agree that a single displacement is a good compromise for the way we handle shells.

    I don't get anymore the unicode error may be it was a glitch in my system.

  8. Log in to comment