better principled refraction for eevee

Issue #333 resolved
Alessandro Padovani created an issue

daz studio 4.14, blender 2.91, diffeo 9744f4b

This may be also related to #330. Since the bsdf option now uses transparency for thin glass as for #326 #332, I see no reason why we don't do the same with the principled option. Actually the principled option uses refraction both for thin glass and volumetric glass.

I use the test scene in #332 for reference. Below it's iray then cycles with the principled option. We can see that the principled node uses refraction for the blue thin glass, thus generating noise.

We can change the principled shader to use transparency for thin glass instead of refraction. An alpha of 0.2 works fine enough.

if thin glass
  principled alpha = 0.2
  principled transmission = 0

Below it's cycles then eevee with the fix, thus using transparency for thin glass. We can see that the principled shader doesn't cast colored shadows for transparency, but the noise is gone. As for eevee we get comparable results as for #332.

Please note that the eevee settings are already fine for thin glass tranparency since they are fixed in #332. Actually this is a bug if we use the principled refraction instead of transparency for thin glass, because refraction needs to be checked in eevee in this case. This is also reported in #330 though they don't get what the issue is.

Comments (18)

  1. Alessandro Padovani reporter

    Or we can use refraction and clip the noisy rays that’s perhaps a better option. As shown below. As a side note the same can be done for the bsdf option, but in that case it makes little sense since it’s easier to switch refraction with transparency.

    Below the result first cycles then eevee. We see there’s no noise in cycles now. The denoiser is off of course. We can see the blue shadow is there now.

    In this case we use refraction for the blue thin glass, so we have to check it in the eevee settings. That’s hashed + hashed + refraction. I also set depth to 1 mm since we know it’s thin walled.

  2. Xin

    I’m not sure about the low Alpha as the first solution does it, it removes a lot of the shading. Alpha Blend is too aggressive, it’s nullifying too much of the shading. It’s like blending a photo on top of another, like you would do in the Compositor. I think Eevee can do better.

    The second solution is better, I will test it later with eyes to see what I get.

    The Light Path branching should be exclusive to Cycles though, it has no effect in Eevee if you are already using Alpha Hashed for Shadows.

    Check the .blend in #330 to see what the problem was there. Maybe you get some new ideas to make this better in the context of eyes, the main concern of this addon. I will try too later.

  3. Alessandro Padovani reporter

    Xin, I don’t know below it's eevee without ray clipping. It gets much darker that seems not good for the blue thin glass. I agree the first solution is not so good it is just an extension of the bsdf idea.

  4. Thomas Larsson repo owner

    I feel that this discussion is a bit over my head, but if principled nodes cannot handle refraction, could one not simply reuse the refraction node group used for the bsdf method. That would not really complicate things, because we would get rid of the second principled node. And it would actually reduce the code size, which is something that I appreciate.

  5. Alessandro Padovani reporter

    Yes I believe that’s asked by Xin in #335.

    We could bring back a separate choice for refractive materials, so the user can choose between bsdf and principled, being principled the clipped rays solution above.

  6. Alessandro Padovani reporter

    I see that commit 5149e26 doesn’t consider either of the solutions above. The default principled is fine enough though, just dark with eevee and noisy with cycles, but acceptable anyway.

    Please Thomas let me know if you’re not interested so I’ll close this one.

  7. Alessandro Padovani reporter

    Closing, since after reading #337 it is clear that the principled option is now intended to be as simple as possible. So the fix above is not required anymore.

  8. Alessandro Padovani reporter

    commit 9108c55

    Thomas, the “none” option works fine enough in most cases, including V7, if you ignore the refraction map. It is intended for those users who may prefer a “pure” principled shader for simple editing, also for export and/or compatibility purposes. Then it is also easy to cut down the “principled” option. So it is also viable to remove the “none” option entirely since “principled” works always better anyway. I still believe that the “principled-plus” and “principled” names reflect better what the options do.

    Also, the name “principled” instead of “none”, is in line with the other principled options that use a “pure” principled node. While “principled-plus” for refraction is a new extension to the default principled features by adding more nodes. So this #333 makes sense for “principled-plus”, since it is intended to enhance the default principled refraction, the same as the double principled does for refraction maps.

    1. opaque: bsdf, principled
    2. refractive: bsdf, principled-plus, principled
    3. hair: hair bsdf, hair principled, principled

    Below it’s V7 with the “none” option without the refraction map, first cycles then eevee. Seems not bad to me for a “pure” principled node.

  9. Thomas Larsson repo owner

    The weight texture is ignored completely in the last commit, and all opaque inputs of the principled node are overwritten by the refractive data. This is a great improvement. Vic7 eyes now look quite nice, and the ring around cornea is gone.

    About the name, the node setups can be described more completely as

    • principled + bsdf
    • principled + principled
    • principled

    so you get my names by removing the first part, which is already specified in the overall material method. I think this makes sense, so I will keep it unless you convince me otherwise.

  10. Alessandro Padovani reporter

    Commit adf7f7a works fine for the “none” option as for the refraction map.

    The name is for the refractive part of the principled option. The “none” name would mean no refractive part, that’s not what happens. What happens is that “none” always uses a single node, while “principled” may use a single or a double node, depending on the case. So “principled-plus” and “principled” better reflects this.

    The “none” name is also misleading as a first look. Since the user gets refraction = none by looking at the screen. Then I see there’s the popup with extensive explanations, but this doesn’t mean that the names are good. That’s a silly issue though so I’ll not insist here anymore.

    Then I see that the ray clipping is not used for the “principled” option (what I’d call “principled-plus”) and I wonder why. That’s an improvement both for cycles and eevee, because it removes the noise from cycles and removes the darkness from eevee as shown above.

    Please let me know if there’s any reason why the ray clipping is not implemented. So I’ll close this dicscussion.

  11. Xin

    I agree with the Light Path node for Cycles to get rid of caustics issues.

    In Eevee you can get rid of shadows directly by setting Shadow Mode to None. It has the advantage that you don’t get some of the noise/ghosting that Alpha Hashed shadowing has, which depends on Eevee settings.

    On the other hand, one possible advantage of keeping Shadow Mode as Alpha Hashed and using the Light Path node in Eevee too could be when you use the double principled method, since the “ray clipping” will only be performed to the refraction branch (the opaque part will still have opaque shadows as it should). So it could be preferred if you use refraction maps with mixed opaque/refraction shading, otherwise, for pure refraction, setting Shadow Mode to None gives a similar result. The color of the Transparent BSDF has some effect in Eevee too, but only its grayscale component (no colored shadows exist in Eevee), which I’m not sure if it is a desirable effect.

    By the way, in Eevee, only the “Is Shadow Ray” input should be used, and only in combination with Shadow Mode set to Alpha Hashed (or the barely used Alpha Clip). The “Is Reflection Ray” is not supported in Eevee.

    So I guess the following would be optimal:

    • In Cycles, do what the image above shows if using a Refraction BSDF or the Principled ndoe for refractions (as opposed to the Transparent BSDF which doesn’t have these issues).
    • In Eevee, under the same conditions (which require SSR to be enabled), first check if Shadow Mode is Alpha Hashed (or Alpha Clip), then do a similar setup but only use the Is Shadow Ray input.

    To be clear: these issues ONLY apply when using either the Refraction BSDF or the Principled node for refraction (not when using Transparent BSDF).

  12. Alessandro Padovani reporter

    I agree with Xin. But to simplify we can also implement the ray clipping as is above. It is useful for principled with transmission = 1, both cycles and eevee. The fact that eevee doesn’t support reflection rays will not harm. As for BSDF we use the transparent shader for thin glass so ray clipping is not necessary nor useful because we don’t use refraction there. It’s the same as Xin says but I feel this way it’s more clear.

    Please implement ray clipping only for the “principled-plus” method. The “none” method (what I’d call “principled”) is intended to be a single node with no fancy addons.

  13. Alessandro Padovani reporter

    As for commit b66b16a the ray clip custom group is good. But ray clipping is intended only for thin glass, that is, when we don’t need true refraction. While commit b66b16a applies ray clipping both to thin glass and volumetric glass.

    Below the test scene, first iray then cycles. The blue thin glass is good, the red volumetric glass is not.

    # ray clipping is only for principled thin glass
    if principled thin glass
      use ray clipping
    

  14. Thomas Larsson repo owner

    Sorry, I missed that. There is a lot to read and I don’t really follow your material discussions. Should be fixed now.

  15. Alessandro Padovani reporter

    Commit 03a9cf8 works fine.

    Please note that the principled shader can't do colored reflections and this is especially visible in the blue ball (we use the tint option to help it a bit though). This is good since pbr reflections are always white. But iray can do colored reflections, so the best option to mimic iray is always bsdf, that can do colored reflections.

  16. Log in to comment