Set up of eyes' materials in Eevee could be improved

Issue #282 resolved
Xin created an issue

Right now, the way eyes shaders are setup on Eevee will sometimes produce shading issues, since Eevee can’t have multiple refractive surfaces layered on top of each other (only the first one will behave correctly). Since the first one is usually the EyeMoisture, the lower ones shouldn’t have Screen Space Refractions enabled or they won’t work correctly.

Comments (68)

  1. Alessandro Padovani

    Hi Xin, as you said yourself, eevee has limitations for refraction, then with complex objects it may fail to deliver an acceptable result. The plugin actually relies on eevee automatic handling for refraction, that works fine for most cases. But the user may have to fix eevee materials in general for complex objects and materials, this is true both for refraction and other materials too since it is a known issue that eevee materials are an approximation of iray, so they may need to be fixed for some cases.

    Then once it is clear that eevee materials may need to be fixed, and this is normal, I don’t know if Thomas can find an automatic solution for complex refraction objects. It may be needed to detect the first refraction surface that hits the camera ray, then disable the underlying refraction surface. I also guess this is dynamic and may depend on the camera and light positions inside the scene.

    Or Thomas could just do a custom fix for the main daz figures, but in this case I guess this wouldn’t include other figures as the one you take as example.

  2. Alessandro Padovani

    That said I’m working on improvements for refraction both for cycles and eevee but I need some time to sort it out for Thomas. Actually I’m more interested in hair improvements.

  3. Xin reporter

    I think figures of the main generations (g3 and g8) use the same eyes' meshes, so you already know the ordering. The difference here is that the regular g3 base figure doesn’t really use the cornea material region (it’s fully transparent), while this one does. But the geometry and ordering is the same, it’s only a difference in textures (especially the use of a mask texture in this figure).

  4. Alessandro Padovani

    Then I believe a custom fix for the main daz figures, following your suggestion, may be viable in this case.

  5. Thomas Larsson repo owner

    I should have time to look at this tomorrow or over the weekend. Turning off screen space reflections should be straightforward, but iirc the plugin turns them on for some other reason. Maybe one can turn them off for refractive materials.

  6. Alessandro Padovani

    Thomas, it is refraction not reflection, and only for the inner layers the top layer must be enabled for eyes to work. Also I didn’t test Xin in any way I just trust what he reports. Below is what I get with eevee with the default G3F eyes and seems good to me. If I get some time I’ll check the figure reported by Xin and the other standard figures. There’s also a possibility that’s just bad settings used by Xin.

  7. Alessandro Padovani

    Tested V7 with daz studio 4.14, blender 2.91 and commit a0e019c. There are issues with eyes but it’s also in cycles, so it’s not specific to eevee. Below it’s cycles for the V7 eye with the principled option for materials. She renders fine with the bsdf option so it’s an issue with the principled conversion. Will investigate what’s happening it may be a transmap issue.

  8. Xin reporter

    That seems to be another issue. I had no problem with cycles in my example (I was even using a previous version that only had the principled shader). Maybe try testing an older version to see if it fixes your issue.

    But the eevee problem I reported exists even in the latest version too since I made sure to test that before opening this issue. So to be clear, the eevee problem exists in both cases: with principled shader (by using the older commit), and with the bsdfs (by using the latest commit). It makes sense since the problem is not with the nodes but with the material options that exist for Eevee in the side panel.

  9. Alessandro Padovani

    Xin, please use the latest version when reporting issues, since it contains improvements and fixes. It makes no sense to report issues using an old version of the plugin.

    As for the eyes, once the principled conversion works fine, we can look at eevee. It makes no sense to look at eevee with the principled conversion broken, it may very well be just a transmap issue.

  10. Alessandro Padovani

    As for the V7 eyes it is a complex matter. I understood what’s the issue but I believe we can’t fix it. In V7 the cornea uses a refraction map to mask the refractive material. Now this mask is completely unuseful since the cornea is fully refractive, so I don’t know what the artist was thinking about. But it is this texture causing the issue.

    This mask is not black and white but it has a grey gradient, then it seems cycles and iray give different interpretations of this gradient. It is transparent for iray and solid for cycles. An easy fix is to remove the texture since as I said it is unuseful in this case. But this is not a material error since the iray material is translated correctly.

  11. Alessandro Padovani

    Luckily as for the Asha figure the issue is different as reported by Xin. And it is also easy to fix since it’s a bug in the eevee properties. Here the cornea and sclera are not a refractive material but just a transmapped geometry. They are also converted correctly by the plugin as the material itself.

    But the eevee properties are wrong. Since refraction is checked even if there’s transmission zero. Refraction has to be checked only if transmission is 1. Please note that transmission should be either zero or one, since it defines the type of material, refractive or not. This is also why the grey gradient in the V7 issue above is so nasty.

  12. Thomas Larsson repo owner

    Looking at the code I see that screen-space refraction is turned on if there is some refraction (either refraction > 0 or texture), or the material is not completely opaque (alpha < 1 or texture). I guess that is not right, But exactly when should it be applied? And should the blend and shadow modes be changed to alpha hashed in the same situations?

  13. Xin reporter

    I think the following would be an improvement:

    • If there are alphas involved, turn on Alpha Hashed (which works with Screen Space Refraction, and can handle grayscale masks instead of just black-white masks).
    • If there is actual transmission in the shader, turn on Screen Space Refraction.

    But some eyes might have transmission in lower layers too, and that would cause problems with Eevee even after following these rules.

    So I believe that you will need a special treatment for eyes in Eevee (and only for the standard eyes in g3 or g8 since those have a known geometry and you know the structure and naming of layers: EyeMoisture, Sclera, etc.).

    Here is the structure, at least for g3:

    1- EyeMoisture geometry goes first, enveloping the eye.

    2- Sclera and Cornea share the same geometry (a ball-like that is almost the same as the EyeMoisture, covering all the visible eye but going under the EyeMoisture).

    3- Iris' geometry is a ring with an actual hole in the middle.

    4- Pupil geometry is a circle goes last, behind the ring and centered in the hole.

    As you can see, the last 2 are not usually problematic since the Iris has an actual hole, and neither the Iris nor Pupil should be refractive.

    EyeMoisture should be refractive for the eyes to look good (I can’t imagine why it would not, but maybe there are some assets where it is fully transparent without refraction for some reason).

    The problem comes with the Sclera and Cornea since they share geometry but they are different materials (Sclera is the white part of the eye, and Cornea covers Iris and Pupil), so the use of masks is common (the Alpha Hashed settings are usually needed because of this). But some vendors might turn on refraction here (not just simple masking) for the Cornea region, following the refraction after the EyeMoisture. This isn’t a problem in Cycles, but can’t be handled in Eevee.

    A simple way to handle g3 eyes in Eevee (g8 too?) would be (Eevee only, no point in messing with this in Cycles and losing fidelity):

    1- Check if EyeMoisture is refractive (whether Screen Space Refractions is turned ON or not)

    1a- If it isn’t, do nothing.

    1b- If it is ON, make sure to turn off Screen Space Refractions (SSR) in Sclera and Cornea (Sclera, the white part of the eye, shouldn’t have it ON to begin with if you follow the logic at the top of this comment). But now it could be the case that Cornea isn’t using a simple mask, and was relying on transmission to show the Iris and Pupil behind (that being the case if Cornea refraction was ON after following the logic at the top of this comment). In that case, Cornea should be transparent, since Eevee simply can’t handle the double Air-EyeMoisture-Cornea refractions.

    Maybe these should be options in the materials panel? seems a little too invasive to be done automatically.

    As an unrelated side note, what do you think about a button to clear all unused material slots in all objects? I find myself doing that a lot.

  14. Xin reporter

    As for the issue that Alessandro Padovani had, I think instead of removing the mask, using it as an alpha mask (remember that Cornea shares geometry with Sclera, and that Alpha Hashed handles grayscale masks well), instead of using it to modulate transmission would work better, and serve to maintain some of the soft transition in Eevee instead of completely getting rid of it.

    But that is for Eevee. I don’t know why Cycles would have a problem with a mask plugged into the Transmission input of the Principled shader. Will check it too, although this is a different issue.

  15. Xin reporter

    Ok, so I checked the V7 issue on Cycles and I noticed that the current commit ignores the color texture for the principled shader of the Cornea, that’s why it’s broken. The mask is not the issue, it uses the mask so the transition from Sclera (which should be opaque) to Cornea (which should be transmissive) is soft. This is the case because Sclera and Cornea share the same geometry shell, at least for g3 (as I explained above).

    It works fine in the middle since the transmission mask is white there; but towards the edges, once the mask turns into black (no transmission), there is no color information (the principled shader has full white as Base Color). This isn’t a problem with BSDF nodes because that method uses the color map (“V7EyeMapD01_1007”) properly for the Cornea too.

    A warning here, the color socket has two meaning in the principled shader if you have a transmission mask: where it isn’t transmitting it affects the color of the opaque surface, which is easy to understand; but where it is transmitting the Base Color input specifies the color that is allowed to be transmitted. White: all colors pass through; Black: none do, effectively blocking transmission. So a non-white Base Color ends up affecting the color of the surface too even when Transmission is 1.

    To sum up, the problem with V7 and Cycles seems to be an oversight with the principled shader method, The Cornea needs to transition into the Sclera texture and it needs a color texture/color information for that, you can’t just ignore it and assume that the Cornea will always be a hole (a fully white transmission mask), and leave the Base Color as white. But getting it right might be non-trivial: just plugging the color map into the Base Color affects the transmission effect too and makes the Cornea look too opaque in the center, where it should be fully transmissive (that is Transmission = 1 and Base Color = 1).

    To be honest, I don’t think it’s worth the hassle to try to fix the handling of eyes materials with the principled node in Cycles, since the principled node isn’t well suited for this case: combination of transmission and non-transmission quickly becomes non-trivial. Combining the simpler BSDF nodes is much better and more intuitive.

  16. Alessandro Padovani

    Thank you Xin for the V7 comment, you are partially right, it is just a little more complex than that. Iray ignores the diffuse color for refractive materials, and it uses the glossy or refraction color dependently from the share glossy input selector. Now since the refraction is masked the cornea border is not refractive and the diffuse color comes into play. So in this case we should mix the glossy color with the diffuse color using the refraction mask.

    Below an example rendered in iray where the refraction mask mixes a red diffuse color with a green glossy color. Test scene included.

    And below the cycles conversion.

    So these are the new equations for the principled glass color

    # principled glass color (iray refraction = 1)
    
    if share glossy input is on
      mycolor = iray glossy color
      principled specular tint = 1
    
    if share glossy input is off
      mycolor = iray refraction color
      principled specular tint = 0
    
    if thin walled is off and iray transmitted color <> [white,black] and iray transmitted distance > 0
      mycolor = mycolor * iray transmitted color
    
    # this is the new case where the refraction is masked
    if refraction weight has a texture
      mycolor = mix(refraction map, iray diffuse color, mycolor)
    
    principled base color = mycolor
    

  17. Alessandro Padovani

    NO.1 EEVEE REFRACTION

    As for screen space refraction I agree with Xin, it is not to be used with transmapped materials, it is only to be used with refractive materials. Also eevee has issues with multiple refraction layers, but it is hard to deal with it and in my opinion it is better to leave that to be fixed by the user, or we may try custom fixes for the main daz figures if needed.

    # turn on eevee screen space refraction
    if glossy layered weight > 0 and refraction weight > 0
        eevee screen space refraction = on
    

  18. Xin reporter

    Alessandro I also thought that combining the refraction map and the base color texture would give decent results, but if you try it you will find out that the white ring persists.

    The issue is the following:

    Suppose you have a 0.4 value for the refraction map value which goes into the transmission input. This means that the principled base color will be (0.4 * base color texture + 0.6 * [some nearly white color]). This ends up being a pale version of the base color texture. The shading done by the principled node is then:

    output = 0.4 * [transmission with pale base color texture] + 0.6 * [opaque with pale base color texture]

    This is wrong, it gives a pale result. What we really wanted is:

    output = 0.4 * [transmission with nearly white color] + 0.6 * [opaque with base color texture]

    This is more or less what the BSDF version does, which is correct. The principled node is quite limited in this aspect since the Base Color is doing two things at the same time and there is no trivial way to separate those functions (refraction color, which should be nearly white, from opaque surface color, which should be the color texture).

  19. Xin reporter

    Here is an example which shows a possible hybrid alternative that could be used in the Principled method, instead of relying on a single principled node to do all the job. Notice how we now have the refraction color input separate from the opaque color input.

  20. Alessandro Padovani

    Xin, I’m not sure I follow. The refraction map drives the glossy color, so in your example it will be 0.4 * glossy + 0.6 * diffuse, that’s what we want. Though it doesn't work with textures as you noted, it seems it only works with colors. I'm wondering if textures make any difference with the refraction gradient.

    Anyway this kind of fix may be better left to the user. Personally I'd delete the refraction map.

  21. Alessandro Padovani

    NO.2 THRESHOLD APPROXIMATION FOR REFRACTIVE MAPS

    The following setup uses a 0.5 threshold for the gradient, and it seems to mimic fine what iray does. May be iray uses a threshold too for refraction textures, that may also make sense since refraction in pbr is supposed to be either zero or one. This is easy to implement and seems a good general purpose fix.

    Below the comparison iray vs cycles both for the “green” eye example and the V7 example with textures.

  22. Xin reporter

    That is turning the mask into a binary mask so the fading disappears, defeating one of its original purposes. The iray one still has that fading (if you look closely you can see it in your screenshots too). So I’m not sure this is the optimal alternative.

    Is there any design reason why the Principled method is tunnel visioning so intensely into trying to make everything work with a single principled node? it’s really not built for non-trivial transmission so it makes no sense to try to force it. I don’t really understand the design decision behind the principled method being so stiff that it doesn’t accept the additional usage of a proper shader for non-trivial transmissions. For opaque surfaces and subsurface, the principled shader alone still works fine, but this is the edge case that it can’t handle. The principled node in Blender is really not the same as the huge iray node in daz. Making the former behave like the latter in this case is not possible.

    Oh and as a side note: Alessandro, did you know that Blender has an AI denoiser now? you can turn it on even if you don’t have a good GPU (there is one that works with the CPU too), so you can get rid of the noise easily. With Cycles selected, go to Render Properties → Sampling → Denoising → check Viewport → select OpenImageDenoise; and then set “Start Sample” equal to Viewport samples above (which can now be way lower since the denoiser is really good) for optimal performance.

  23. Alessandro Padovani

    Yep I know of the denoiser, when doing tests I leave it off both in cycles and iray to better see what the rendering does, since the denoiser can introduce fakes.

    As for the principled shader, I like to keep it simple because this is what it is designed for. The principled option is intended to target eevee and compatible engines such as prorender and to help gltf export and game engines exporting in general. Also the principled shader has limits over the uber shader as you said yourself so it is not possible anyway to convert iray properly. Not to talk about eevee limitations. Here it is expected for the user to eventually fix complex materials.

    Then we have the bsdf option for “full” iray materials, where we try to mimic iray by any means possible. For this reason bsdf nodes are used instead of the principled shader because they are much more flexible. Also here we don’t care of eevee limitations, though Thomas is leaving the option to also use eevee, that personally I’d not.

    So the general philosophy is:

    • principled option: for cycles and eevee, limited iray materials.
    • bsdf option: for cycles only, full iray materials.

  24. Alessandro Padovani

    p.s. Also in your setup the refraction will lose specularity, that’s not desirable. It is the same reason why we can’t mix the principled shader with the translucent shader. That is, the principled shader is designed to be simple and it works best alone.

  25. Xin reporter

    You can combine two principled shaders (one with transmission=1, the other with transmission=0) with a mix shader instead of using the refraction shader if you want the fresnel reflections for transmission too. This also ends up separating the Base Colors for transmission and non-transmission, which is what we wanted. And Eevee can handle that (and a lot more).

    I still don’t really see any strong reason why using a single principled node is a rule that should be enforced everywhere (especially for transmission where it falls apart). That is not a rule Eevee enforces, and it makes the material look closer to the original when using Eevee, which sometimes can’t handle the BSDF method. Even then, Eevee still has the problem that I originally reported in this Issue.

    The original motivation for the principled node in Blender was to have a PBR-friendly node that models most materials without having a lot of parameters that make tweaking the material tedious and error-prone (as in breaking PBR rules).

    That principle wouldn’t be broken here since one principled node is modeling transmission and the other the opaque part. As long as you don’t start going crazy like the BSDF method does, and ending up with a lot of parameters (making it hard for the user to tweak), you will still be respecting that principle. For a Blender importer, respecting material fidelity in Blender is a more important principle in my opinion than insisting on using a single principled node everywhere, under all circumstances, for no strong reason.

  26. Alessandro Padovani

    Mixing two principled nodes seems a very good idea to me. This will correctly solve materials with a refraction map. Still there are many things that the principled node simply can’t do, as colored specularity, surface translucency, volumetric sss to name a few. And honestly I believe “going south” with complexity is not a good idea for the principled option, that is reserved to the bsdf option.

    For this reason I like more the threshold approach, but the dual principled is good. Then Thomas will decide what he likes better.

    Xin, I am also very glad to have someone here who understands materials, you seem very good at it. So thank you for your comments and suggestions, and I hope you’ll do more.

  27. engetudouiti

    There is no merit to use dual principled shader. but Actually I had already recommended Principled + custom shader as Principled option. Only about how refraction shader work.

    I think Xin say samethings what I requested before.

    At same time, I understand, even though some one offer custom shader nodes and conversion process, with their thinking, they may not work for all daz free iray mixing manner and options.

    As same as Xin, I simply make my custom shader node (principled BSDF + custom shader ) then switch nodes for cycles and Eevee for daz genesis3 figure mat . (you can set driver too, if you hope)

    basically it need to set eye around surface correctly. after import with this add on. so I simply use my group shader, then tweak it. (so it not depend much how daz vendor offer eye around mat, I just need textures, and re-locate them as I need, with set custom value)

    I prefer keep princpled bsdf as base to much for other aprication. because after all I may tweak as I like so generate too many original group nodes by add on is not flexible for me

    (eg I often tweak textures in 3d coat etc, but most of them not work with current add on BSDF complex shader nodes. then after all I set up again. with simple node set up, to plug easy other app generated textures. (usually it much with principled bsdf, pbr manner)

    So keep one princplied BSDF shader + custom shader nodes only about refraction, SSS things. (If user hope to re-produce daz iray shader, but I think it depend on each user. )

    It not fault of current add on set up, but I think it is limit about current cycles ,eevee and iray conversion. and even though only some add on user content with auto conversion process.

    there are tons of real material knowledge user about cycles. eevee , then after all they may not plan auto-conversion. but I suppose they may prefer make custom node set-up, then tweak with improted textrues.

  28. Xin reporter

    I’m also glad Alessandro that you are helping Thomas, since the scope of this script is becoming too big for one person to handle all the time, and you understand the daz side well too.

    I was considering helping with sorting out the documentation next, there are a lot of interesting blog posts scattered around that would benefit from being put in one place and categorized, so people can learn how to effectively use the addon easier (and maybe give well informed feedback), and also so people can find out how to resolve the most common problems easier. Sometimes it’s not clear certain tasks are possible by just looking at each button’s label in isolation, and the blog posts are well written from what I have seen.

  29. Alessandro Padovani

    Xin, the thing is that diffeo is evolving so fast that writing up to date docs could be a real job. Then Thomas is doing a fair job in my opinion updating the user manual and the blog.

    That said a good documentation is always nice. I can give advice for what I know if you need any help.

  30. Thomas Larsson repo owner

    Xin, there is a list of blog post sorted by category at https://diffeomorphic.blogspot.com/p/list-of-blog-posts.html. It is not perfect, but much better than Blogger's right-hand pane which only shows the posts from one month at a time.

    It will soon be time for a new release and updated documentation. This will also mean a feature freeze. I don’t mind writing docs, but it takes a lot of effort and if things change soon thereafter that work is wasted. The problem is that I have started to use the plugin for my own personal projects, and I keep encountering problems that can be solved by adding more functionality.

    And I don’t follow this thread closely. Once you have sorted out how things should be improved, please let me know.

  31. Alessandro Padovani

    Thomas, we already sorted it out, and there are multiple solutions. You can choose what you like but you have to read this discussion to understand things. Personally I’d go with:

    1. use eevee screen space refraction only for refractive materials, not for transmapped materials.
    2. ignore the refraction map for the principled shader, or use a threshold approximation.

    I marked my relative posts as NO.1 and NO.2 in bold so you can find them easily.

  32. Thomas Larsson repo owner

    Now I have tried to wrap my head around this issue, and think that the last commit is a rather good solution. Basically I go with Xin’s suggestion and add a separate refraction node group if there is a texture, or if the refractive weight < 1. This is the same node group that is added in the bsdf method, so glossiness should be included.

    But I also added a new global setting: Ignore Refraction Maps. If this is on, textures are ignored and weight = 1, independent of the value in the duf file, and only the principled node is used.

    Screen space refraction is only added if the material is refractive, not if it just has alpha < 1. However, the blend and shadow modes are still set to alpha hashed even if there is just refraction. Not sure if this is right or if it matters at all.

    I have tested with a number of figures and different settings, and all results look reasonable to me.

  33. Thomas Larsson repo owner

    There were some problems with the previous commit. The new global settings has been changed to Limit Refraction Maps. If true, Alessandro’s threshold approximation is used, otherwise a refraction node group is created. The refraction map is no longer ignored.

    Eye reflections seem to be gone with the extra node group. I don’t understand that, since the node group contains a glossy bsdf which should add reflections, but I’m to tired to think anymore.

  34. Thomas Larsson repo owner

    I changed the name of the option again. Now it is called Refraction Node, and if true a separate refraction node is generated.

    Don’t know why I didn’t see eye reflections before, because now they are there. Here is Vic 7 with the three methods. The problem with the threshold method is that the pupil is too large, like she has dripped belladonna into her eyes. That is of course a kind of beauty ideal, but not what we are after here.

  35. Thomas Larsson repo owner

    Here are the same scenes rendered in eevee. Again, something is weird with the threshold method.

  36. Xin reporter

    Thanks for the changes Thomas

    The other solution we discussed to avoid the refraction node was to mix two principled nodes (one with transmission = 1, the other with transmission = 0) with the refraction map as the Fac input of the Mix Shader. This would retain the glossiness too, and I believe it would make the tweaking of the material easier in the Principled mode.

    Also, I will look into the other issue of the Screen Space Refractions and see if it works well now.

  37. Thomas Larsson repo owner

    Xin, is there an advantage to use a second principled node over the refraction node group? The advantage with the second approach is that I can reuse the code from the bsdf method.

  38. Xin reporter

    Not really if the refraction node is well set up, I was suggesting the double principled nodes as an alternative to the threshold method (when Refraction Node is not checked).

    That aside, is there any reason why the EyeMoisture material has Alpha = 0 with the Principled method (tested with V7)? that shouldn’t be the case, at least for Cycles since Cycles can handle stacked refractive surfaces. As for Eevee, I will sum up my post above offering a solution once you reply (in case this is a bug), but forcing the EyeMoisture to be invisible is not a good idea even on Eevee since it’s the main surface that makes the eye look glossy.

  39. Thomas Larsson repo owner

    I think the refraction node is rather good, and if it isn’t improvements would benefit the bsdf method as well.

    Eyemoisture has alpha = 0 because cutout opacity = 0 in DS (I assume you talk about Victoria 7).

  40. Xin reporter

    Oh ok, thought it was a bug. Then I believe no more fixes are needed for my original problem (the one regarding the Screen Space Refractions), because if for some reason a vendor makes both the Cornea and EyeMoisture refractive, the script will now turn Screen Space Refractions ON in both materials. When rendering, Eevee will only calculate refraction on the first surface (the EyeMoisture), and completely ignore the Cornea (effectively making it transparent on the part which has Screen Space Refractions ON). This gives good enough results for the cases I tested.

    The important part was to fix the masking issue (the script confusing masking with refraction) which you have already fixed. So this issue can be considered resolved.


    As for the other one, it’s up to you: whether to get rid of the Refraction Node option for the Principled Method altogether and just use it without asking; or insist on keeping the Principled Method free of custom nodes and use the double principled workaround; or just keep the threshold method as an option as it is right now.

    The issue I see with using the custom Refraction Node without asking is that future changes to it could break compatibility with Eevee, while the double Principled will always work. Also, tweaking parameters on the custom node might not be as intuitive as with the double Principled (you have to understand what the custom Refraction Node does, basically see what’s inside the group).

  41. Alessandro Padovani

    Thomas the refraction node doesn’t work because this way you miss the top coat that’s the main source of reflection for the cornea. Indeed the reflections you see in your tests are from the eyemoisture, not from the cornea. Anyway there are issues with top coat that’s too high for bsdf and too low for prinicipled, but I’d not add them here and eventually will open another discussion.

    Apart the top coat failure commit 81920bb seems good enough to me. Personally I’d mark as resolved.

  42. engetudouiti

    @Thomas

    Well done. The only thing you may better not call it as custom refraction, but custom glass shader (for blender) which mimic fresnel reflection with thin (no volume) refraction. blender not count reflection for refraction shader.

    But it is OK for me.

    the node set up is now almost same as my setting. (So I recommended it before, add custom shader (which represent daz thin wall, and mix with refraction weight) with principled bsdf for principled bsdf mode, but about that time, you hope to keep simple for principled shader mode. (you did not hope to add new shader for principled mode)

    at same time, as alessandro said, it may not offer daz top-coat glossy. because it layered over of all. But I can not reproduce it by just add new glossy shader. I may hope to see how someone solve this issue.

  43. engetudouiti

    And one thing (it is not about top coat)

    The only problem if you use current custom glass shader, with refraction weight, it can not work well if the iray mat refraction come with volume.

    The reason is how we made “custom fresnel node” to represent, real roughness fresnel reflection in blender as PBR manner for fresnel.

    to rerproduce it, you may need to add new blender glass bsdf shader in your current custom refraction node, then exchange it with volume off or volume on .

    About both case, if script try to auto-generate daz refraction, we may not need to use principled bsdf transfmission. because mixing order is different from daz iray default sahder and cycles principled bsdf.

    Eventhough you do all things, there still issue when it come with thin wall plane. the custom fresnel node not work well, with reverse angle. about the case we can not use the custom fresnel node. (so it means you may see hard edge as fresnel, even though you set high roughness. But it is acceptable.

    The coustom fresnel node actually work well for all non refractive material. (it offer more correct fresnel reflection with roughness value)

    But the custom fresnel node not work well when we use it for refractive material.

    How manage it, depend user I think. (so omeone may not need the custom fresnel at all, or someone still use custom fresnel node, but not try to mimic thin wall refraction etc)

    ===

    And why it made somehow complex, we tried to mimic 2 things at same time before.

    1. represent thin wall refractive material with mix 2 ior.
    2. represent fresnel reflection witch show more relaistic with current roughenss value.

    The real author who offer node set up for custom fresnel nodes, actually said, he do not think it work well when it is used to mimic glass shader. (though he seems offered custom glass shader too, but it is not for thin wall compatible)

    So I recommended to use the custom fresnel node for eye surface daz refraction. but when it is used for plane thin wall glass with change view, it may show issue. (and about the case, I do not use custom fresnel node, (manually exchange it)

  44. engetudouiti

    And I curently using this shader node group to mimic thin wall = refraction ior 1.00

    it work for both side

    https://devtalk.blender.org/uploads/default/original/2X/1/1ed44eaa06867c55a72b54e2cdc56aa1f1dc72e6.jpg

    it offered by cdog in blender developer forum.

    unfortunatelly, it can not use custom fresnel nodes which count rougnness correctly.

    The reason is, I think custom fresnel need to use surface normal value to mimic fresnel which work with roughness. it offer miss ciruclate about back face I suppose

    I believe, there should be good way, to mix use.. But I do not have time to get it work (mix custom fresnel withc use face normal, with the volume or thin wall glass set up which work for all)

  45. Thomas Larsson repo owner

    As Xin suggested, I replaced the custom refraction group with a second principled node. The new way yields more eye reflections, which I think I prefer.

  46. Xin reporter

    Thanks again for the changes Thomas, I also prefer it this way, since the custom refraction group can now be tweaked to maximize fidelity under Cycles without concerns for respecting Eevee’s limits.

    As a last suggestion, the option name in Global Settings should probably be changed to “double principled” or something like that (or maybe just use the double principled automatically and get rid of the option altogether?).

    The other discussion about emulating Iray’s Uber shader is more of a Cycles thing, and concerns the BSDF method, which attempts to achieve that. The Principled method already fixed the issues it had with supporting Eevee, so that other discussion should be moved to a new Issue. I consider this issue resolved.

  47. engetudouiti

    Thomas it is because you just add and emphasize clearcoat reflection .

    so current shader only use clear coat reflection for all transmission part. (reflactive weighted part with map)

    at same time now it auto set new principled bsdf ior reflection value as 1.00 for all refractive part. (with thin wall)

    When you set transmission as 1.00, princpled bsdf only use ior for normal reflection strength. that means second principled bsdf reflection is zero. (actually)

    iray use reflaction index for all refractive material reflection. so you can still get clear reflection even though it is thin wall. (as refraction iray count ior as 1.00 , then reflect with ior reflaction index for thin wall mat, though actually it is more complex I suppose for mulit scatter)

    to represent it for blender principled transmission as thin wall, , we need to change ior only about reflection, with keep reflactive ior value as 1.00 , but principled bsdf never work so.

    custom shader nodes included it. Now you add clearcoat so you feel it show more reflective ,which only show daz top coat reflective without circulate correctly.

    Then it may only work for surfaces which use daz topcoats. (though actually it never show values correctly) then when top coat is not used, the surface simply remove all reflection about thin wall reflactive mat.

    And daz top coat change how each value effect with option (reflective only etc, you think it work for Victoria 7, but I do not suppose it work for other setting skin materials cornea at all)

  48. Xin reporter

    The reason you have clearcoat with V7 is because the EyeMoisture material is fully transparent, so the material is set up so the Cornea and Sclera use clearcoat instead of the EyeMoisture geometry for the humidity of the eye. This is not something Thomas added himself to create reflections out of thin air, but the way V7’s eyes are set up. Most other figures use the EyeMoisture surface instead of clearcoat, and in that case the material for the EyeMoisture is simple, even in Eevee (a single principled shader can handle it).

  49. engetudouiti

    And if you felt about less reflection for your custom reflaction nodes, you only needed to add some extra ior value in your custom fresnel node. .

    there is almost no need to add top coat for cornea. because you could controll it as ior value of custom shader as you like. sitll keep your set glossy color .

    This pic only set color for custom glass shader, though I do not check all your node set up, but it should be almost same I thought. Then I apply it for cornea with principled bsdf, (mix by reflraction map) eye moisture reflection color keep pure white, so it clear see, cornea show reflection. witch controlled by custom shader fresnel ior value.

    double principled bsdf can not do it for thin wall refractive mat. (it need to keep 1.00 = no base reflection)

    My character skin (which imported) not use daz top coat for cornea , so if I simply use current princpled bsdf option, it never show any reflectivity , I suppose, without you force to add clearcoat for all cornea.

    but if you use (you now removed) custom shader, I may just needed to change ior in custom shader nodes, without cycles top-coat etc. So I said, double princiled never offer improvement as true meaning .it happend to work well for skins which used daz top-coat then we see the effect only as reflection for thin refractive mats.

    Then if I really hope to represent daz top coat, I may add new shader (but it depend and change hard with daz top coat option settiing, so it can not easy mimic daz way)

  50. Xin reporter

    My character skin (which imported) not use daz top coat for cornea , so if I simply use current princpled bsdf option, it never show any reflectivity , I suppose, without you force to add clearcoat for all cornea.

    That’s because the principled shader for transmission has IOR left as 1 when it should be set up to the correct value,

    But if it still doesn’t work, then something is wrong with your material. The main reflections come from one of two sources (in Eevee, Cycles can have both at the same time):

    1- EyeMoisture material (most common).

    2- If EyeMoisture is deactivated (by setting its opacity to 0 like V7 does), then the Cornea and Sclera must have clearcoat on them (this MUST be set up in daz, it’s not a problem with this script). Otherwise you will have a very weird and dry looking eye where reflections only come from Fresnel reflections, which aren’t enough to give the correct look.

  51. engetudouiti

    you do not understand why we need to set ior for thin wall refractive mat . please check it in daz studio. now you see eye cornea set thin wall . that means, it not count ior for refraction. but still use ior for reflection.

    so if you set it as 1.3 or 1.4 etc, for double principled bsdf, the ior used as refraction .

    it may change covered pupil size (because refraction value change) of course you can ignore it, but I do not ignore it.

  52. engetudouiti

    And I do not recommend, but to get more reasonable effect, with principled shader only, actually you needed 3 principled bsdf.

    1. base shader (non refracve part)
    2. refractive part refraction (set ior as 1.0 etc)
    3. refractive part reflection (set ior as 1.3 etc)

    you may not hope it. I suppose. And I dd not plan to reqeust add another shader for principled bsdf option. but I felt finally Thomas added it, then I said, how it work .

    Actually as my view, it depend on user, so do not care how others use shader.

    and not care Thomas offer options. (I can see some merit, eg now I can mix use clear coat if I use it) but, if add new principled bsdf, I expect it work better than before.

    unfortunately if use 2 principles bsdf, it not offer usabliltiy (eg you can no set up glossy color any more = iray do ) and why I said it not work, principled bsdf can not divide ior. so if only add one principled bsdf = it only offer mix use with refraction map. about refractive part , it still use same ior for both.

    you can set it as 1.0 = refraction correct. but reflection is wrong

    you can set it as 1.2 or 1.3 = refraction correct (it is reason I do not prefer it), reflection is correct (show reflectivitiy)

    so with use refraciton map, you need 3 principles bsdf. or I may prefer use custom glass shader (which offered only a few minutes)

    But after all as I said I already have made it for my purpose, so do not reject current set up. just offer my small knowledge how it may work.

  53. Xin reporter

    That’s how refraction works under Eevee. If you want to control the size at the same time, you can use the Refraction Depth settings in Eevee, and set it up to something like 0.0001 m. But the effect is so subtle (can you give a specific example?), that it should be left up to the user (or maybe Thomas could just set it up to 0.0001 m by default).

    As for the color of reflections, you can’t change them even with a single principled node which is used for most materials, that’s the nature of this PBR node (it’s supposed to be simple and physically based, not the Uber shader) It’s up to you to make those odd, non-PBR effects, not the importer, or else use the BSDF method (under Global Settings).

    Maybe as a Quality of Life change, Thomas could let people add the custom nodes used in the BSDF method to material graphs even after choosing the Principled Method (a button in the Material panel maybe?). But I’m not sure that’s a feature most people would ever use.

  54. engetudouiti

    you need not to show me, Eevee mat setting. or you means now those option can use for cycles too? or you only talk about Eevee, but you recommend use same shader for both?

  55. Xin reporter

    This Issue was about Eevee which can’t handle the BSDF method in a lot of situations so I asked Thomas to improve Eevee support with the Principled method.

    For Cycles, go to Global Settings and set up the following before import:

    This will give you a lot of custom nodes which let you tweak almost everything you could want.

  56. engetudouiti

    If you really talked only about Eevee, actually there was no merit to use double princpled. but just needed to add transparent shader with glossy shader. but I actually do not hope to keep this topic, so OK it seems work well for eevee.

  57. Thomas Larsson repo owner

    The double principled setup has one property that I like: in the limit that a partially refractive material becomes fully refractive, the two nodes are equivalent to the single node for a fully refractive material. The opaque node is then completely shadowed by the mix node and can be removed.

    So if there are problems with the double node setup, the same problems should be there also for the single node setup for fully refractive materials.

  58. engetudouiti

    double principled way better than single one. because it can use refractive mat as same as daz manner. so now you can mix, metal and glass with refractive weight map. it is good thing. then of course now you can free customize 2nd principled bsdf as you like (or use mix node etc)

    But if it need why you simply change all node as dobule principled? because it offer more variation.

    I said there is no meaning mix same 2 uber type shader as uber option for refractive mat. . if I can add another shader. I may prefer add another nodes which only need for the prupose and work correctly. ,

    double principled bsdf node set up can not show any reflection without using clear-coat . You can see it when remove the clearcoat value. then try to change reflection. you know you should not change the second principled bsdf ior value for cornea and eye moisture (refractive mat) it should be 1.0 as daz thin wall mat, like eye moisture or cornea to show thin refractive = tanasparent refraction correctly.

    at same time, you have used fresnel node to set reflectton with fresenel ior. so you could keep refractive ior = 1.00 (or can use transparent shader) but use fresnel ior to change reflection.

    Then it can keep the reflection correspond with daz set ior for thin-wall (like bubble etc) without using topcoat. now the double principled bsdf refractive mat only show clearcoat reflection.

    Of course the first Xin report was correct. I said before, we need to use fresnel and transparent shader for Eevee 2nd surface to make it work (and you did so) as my first Eevee reprot.

    But at that time, I do not push to mix with principled bsdf to use refraction mat. it is because I thought you may not hope to mix shaders for princpled option. then just exchange refractive mat as custom refraction nodes only for those 2 part. it work without problem.

    V7 use refraction mat to separate base and refractive part for cornea.

    To solve it actually we only needed to mix principled bsdf as non refractive part, with the custom shader. but you prefer to use double principled, then it lost to get reflection with daz set ior value. principled bsdf not offer to set fresnel ior and refraction ior separately for refractive mat.. so without you add fresnel nodes, you can never divide it.

    Actually things was simple.

    1. we need custom nodes to get thin wall reflectivity (with use ior)
    2. we need to mix with principled shader (for non refractive part mixing material)

    my prefered answer was just mix 2 . for me 1 is more important, and 2 can be done without double principled bsdf.

    current way = double principled bsdf offer 2. but remove 1. (but can use clearcoat for refraction, it may only mimic daz top coat (partially)

    That was reason I recommend to keep custom nodes for principled . But after all I may exchange the 2nd principled bsdf as I need. at least for thin wall erflactive mat, like eyemoisture etc.

  59. Xin reporter

    I get what engetudouiti is saying now, he was using the Principled method for Cycles but Cycles has no Refraction Depth option to emulate thin walls like Eevee, so he preferred the custom refraction node in the Principled method to handle that.

    To sum it up for Thomas, the problem is the following:

    Refraction through a thin volume (like the humidity layer of the eye) behaves as if the IOR was 1 for the purposes of transmission, since the ray is barely deviated if the volume is thin.

    Cycles calculates refraction assuming all surfaces enclose a volume. That is, refraction through a single plane (like the Cornea or EyeMoisture geometry) never transitions back to air because a single plane encloses no volume, so Cycles effectively treats it like an infinite volume. In Daz there is the Thin Walled boolean in the uber shader to tell the engine to treat the plane as a very thin volume instead. The workaround in Cycles is to make the IOR = 1 for transmission or just use a Transparent BSDF.

    But Fresnel reflections still depend on the IOR, so we can’t just use a Principled node with IOR = 1 or we lose the Fresnel reflections (ignore clearcoat for now). To get those Fresnel reflections the principled node used for refraction must have the correct IOR (that is, not 1 but the IOR from the daz material). This means that the principled node used for refraction needs two different IORs in Cycles: 1 to emulate the thin volume, and the real IOR to get correct Fresnel reflections. Of course, there is no way to do that.

    On the other hand, in Eevee, we have a material setting, Refraction Depth, which calculates two refraction events based on the depth, effectively simulating a thin volume if we make the depth small enough (like the 0.0001 m I used above). So the double principled works quite well in Eevee even if we want correct Fresnel reflections: just set the IOR of the principled node used for refraction to the real IOR, and use the Refraction Depth to make it thin.

    I don’t really know what’s the best solution for Cycles when using the Principled method. The double principled will have some distortion under Cycles, but works quite well for Eevee while keeping it simple. Maybe using the custom DAZ Refraction node but just for the Cycles output of the shader? or maybe bringing back the setting to let the user use the Refraction node in the Principled method? it’s up to you Thomas.

  60. Thomas Larsson repo owner

    Xin, you cannot ignore clearcoat, because it is added by the plugin to emulate reflections in the thin walled case. I don’t have a link to Alessandro’s original report, but the comment in pbr.py line 260 explains how the conversion is done:

                # if thin walled is on then there's no volume
                # and we use the clearcoat channel for reflections
                #  principled ior = 1
                #  principled roughness = 0
                #  principled clearcoat = (iray refraction index - 1) * 10 * iray glossy layered weight
                #  principled clearcoat roughness = 0
    

    If thin wall is off, the conversion is

                # principled specular = 0.5
                # principled ior = iray refraction index
                # principled roughness = iray glossy roughness
    

  61. Xin reporter

    Oh ok, so the plugin uses clearcoat to fake the thin wall effect (I’m assuming only with the Principled Method, since you can get better accuracy with the custom nodes). That might give decent enough results. I suppose the daz Top Coat Weight, if any, is also considered?

    If that’s the approach that the plugin takes with the Principled Method to handle thin walls, then the double principled can’t introduce a problem that didn’t already exist. But that’s another Issue. I will consider this resolved, since the masking/refraction issue in Eevee was resolved, and Eevee works quite well with the double principled so it can handle refraction textures well too.

    Thanks again for the changes Thomas.

  62. Log in to comment