refractive shells don't work (and solution)

Issue #558 resolved
Alessandro Padovani created an issue

daz studio 4.15.0.2, blender 2.93.0, commit 56ecd1a

This is related to #543 but I'm reporting it here for better handling. I managed to make a simple daz scene showing the bug. It's a cube with a shell that's both transparent and refractive, as it happens to be in the ultimate moisture shell.

In this case the cube is rendered as transparent in blender. That is, the shell refraction gets mixed with the underling material that's not good, because we want the shell to be refractive thus showing the underling surface that's reflective.

In this case a simple solution is to give the shell its own geometry. I'm not sure if there's a possible fix just layering materials. I'm working on it but so far didn't get it. So anyone interested please help.

Test scene included ref-shell.duf. Below first iray then cycles. We can see that in cycles the inner cube is visible because the outer cube is refractive.

Comments (22)

  1. Alessandro Padovani reporter

    Of course one quick fix is to ignore refraction if we get a refractive shell. This way we only consider the shell opacity. But rather than a fix this is a gross approximation and the material will not be the same.

  2. Alessandro Padovani reporter

    update. important.

    Please note that if the base material is volumetric, then the refractive shell works fine enough. Because in this case the base material needs anyway a translucent surface to show the volume. This is why ultimate moisture for G8F works fine with bsdf but doesn’t work with principled, since bsdf provides a volumetric skin.

    Below a couple of examples with ultimate moisture for G8F, and a cube with volumetric material. The volumetric cube test scene is included skin-shell.duf.

  3. Alessandro Padovani reporter

    refractive shell over a volumetric skin, in this case the mixed refraction is not a problem because the skin needs to be transparent to show the inner volume

  4. Alessandro Padovani reporter

    UPDATE. SOLUTION.

    Ok may be I got a really dirty trick that seems to work fine enough with some approximation. Again the exact solution would be to provide the shell with its own geometry.

    Luckily we can count on some attributes for refractive shells.

    1. Since it's a shell it is thin walled, so we get a simplified refraction.
    2. Since the shell is refractive, it is already "transparent" and we can ignore the opacity with some approximation.

    With the conditions above we can use the add shader instead of the mix shader to overlay the shell. This requires the diffuse color to be black to preserve the energy, luckily again that's not an issue since the diffuse color is ignored by refractive materials in iray. This way only the shell reflections will be overlayed, that's what we want.

    So following the idea above, below it is the refractive shell setup for the bsdf and principled options.

    Then below some examples of the fix, with the cube and the principled moisture that didn’t work before.

  5. Alessandro Padovani reporter

    Thomas, please wait to implement because I have improvements. Specifically I managed to get back the opacity somehow, but I need some tests before publishing.

  6. Alessandro Padovani reporter

    Ok below are the bsdf and principled setups including opacity. Basically I added the opacity filter before the add shader. That is how the reference scene ref-shell.duf has to be converted.

    Again please note that the base colors are black because of the add shader. Thomas of course feel free to ask if something is not clear.

  7. Alessandro Padovani reporter

    Commit cdf2fe7 works fine. But there’s a bug that’s my fault I didn’t notice it before.

    In the principled option we need “transmission = 0”. Otherwise the refraction bump is not visible and only the clearcoat bump is rendered. Then I have no idea why but I guess it has something to do with the add shader.

    Please note that this is only for the principled option, the bsdf option is fine with “daz refraction fac = 1” as it is already. That’s also more confusing but this is it.

  8. Alessandro Padovani reporter

    SEMI-REFRACTIVE SHELLS

    daz studio 4.15.0.30, blender 2.93.6, diffeomorphic 1.6.1.0726

    This is related to #778. The solution above we got for refractive shells is for 100% refraction, where the diffuse channel is ignored in iray. If refraction is 50% or so we get in iray a mix between the diffusion and glossy channels. Please note that in real physics the refraction is binary, that is, a material is either refractive or not, it doesn't exists a 50% refractive material. So this is just a CGI trick to mix diffusion and refraction.

    We'll take as example the realistic tears in #778. Test scene tears-wet.duf where we get a 50% refractive shell. This means the glossy channel is visible at 50% and the diffuse channel at 50%.

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

    Below the solution for the principled option. We get a glossy channel, a diffuse channel, and the mix. The glossy channel is the same as the solution above, it's the 100% refractive shell no modifications are done. Please note that the base color in the glossy channel is black, that is, there's no diffusion. The diffuse channel is added above the the glossy channel, here the diffusion gets mixed with the cutout opacity, the same as the glossy channel is. Finally glossy and diffuse are mixed by the refraction weight, a 100% refraction will show only the glossy, and a 0% refraction only the diffuse channel.

    Below I simplified the diffusion with no reflection, just for demonstration purposes.

    # semi-refractive shells
    glossy = 100% refractive shell
    diffuse = 0% refractive shell
    mix = refraction weight
    

    Below the solution for the bsdf option. The principle is the same. Again please note that the refraction group gets no input for cycles and eevee, that is, there's no diffusion.

  9. Alessandro Padovani reporter

    Below the test scene tears-wet.duf in iray then cycles with the fix above.

  10. Thomas Larsson repo owner

    I have started to work on this. However, it is not ready and pushing the last commit already was a mistake.

  11. Alessandro Padovani reporter

    If it is easier, may be you can generate two shells 100% 0% refractive then mix them. Of course one “optimized“ shell would be better.

  12. Thomas Larsson repo owner

    Mostly implemented, but there are some things that I don’t understand.

    In the bsdf case, why is Fac = 0.050. The refraction weight = 0.5 is covered by the final mix nodes, so I put Fac = 1.0 in the DAZ Refraction node.

    In the principled case, Transmission = 1 for the same reason.

    Bsdf opaque and principled refraction can not be combined, so I use the principled and second principled settings.

  13. Alessandro Padovani reporter

    As for the 0.05 fac it’s my fault there’s an error in the picture. The original refraction was 0.05 before I changed it to 0.5 and I forgot to update. So fac = 1.0 is good.

    As for the principled case, for 100% refraction we need transmission = 0 for it to work fine. It has something to do with the add shaders but I don’t fully understand it myself. This was already noted and fixed though. See above 2021-06-08.

    As for principled and second principled that makes sense I also agree.

  14. Alessandro Padovani reporter

    As for commit 0ebc511, the principled option seems to lose the diffuse color in the second principled, thus the tears in the test scene are black instead of red. The principled transmission = 0 is already fixed from what I see.

  15. Alessandro Padovani reporter

    Commit 082575c works as intended, marking as resolved.

    I still see some difference with the various tears options and sometime we have to adjust the shell influence or the fresnel IOR inside the shell. Not sure why, will update if I find something. However this is a big improvement both for refractive shells and layered images. Thank you Thomas for the nice work.

  16. Log in to comment