uber weighted mode
This is related to #857.
We don’t actually support the “weighted“ mode for materials. This material mode is rarely used but there are some assets using it. Personally I can’t get what it does and unless there’s a strong request I’m not sure it’s worth the time to study and implement.
It would be useful though to throw a warning if this material mode is encountered, so the user is aware that the specific material may not be converted fine. Or a note in the docs may also be enough.
Comments (33)
-
-
reporter Thank you M.A. I see it adds a “diffuse weight“ factor, may be it’s not that hard to deal with. Will do some tests and expand what I find. Please feel free to add more information or suggestions if you feel they may be useful.
-
This should be all you need. I think this workflow is for when you don’t have a specular map (which goes in the glossy layered weight field of the other mixing types) and just want to set the ratio of diffuse and specular manually. 3Delight shaders have two separate sliders for diffuse and glossy so this might be useful for converting those too.
-
reporter That will not work by your description, but yes I got the idea. Thank you.
-
Yes it should’ve been divide by the sum of the two weights not divide by 2.0.
-
reporter Nope that doesn’t either, if 100% diffuse has to be. I guess we need two mixes will work on this soon as I get some time.
-
reporter - changed title to uber weighted mode
-
reporter daz studio 4.15.0.30, blender 3.0.1, diffeomorphic 1.6.1.0868
Ok I believe I got it.
The weighted mode adds a "diffuse weight" and a "glossy weight" and mixes diffuse with glossy plus refraction. It also removes the "glossy layered weight" and "glossy reflectivity" and seems to maximise them instead. Please note that "glossy weight" and "glossy layered weight" are two completely different things. The first is a overall mix and affects both glossy and refraction, while the second is a glossy factor and only affects glossy.
Below an example. First we have the pbr mode where diffuse is an input to glossy. Then we have the weighted mode where diffuse and glossy are mixed. Test scenes included daz-weighted.duf and daz-weighted.blend. The blender scene includes the groups definitions and can be used to test variuos combinations of the pbr and weighted modes.
Below an example of weighted mode using the new equations and setups. First iray then cycles.
-
reporter Below the weighted group definition.
# DAZ WEIGHTED # the weighted mode mixes diffuse with glossy + refraction fac = iray glossy weight / (iray glossy weight + iray diffuse weight)
-
reporter We forgot to update the refraction group with anisotropy. It's the same as
. Below the setup.#786There's also a couple bugs because the glossy roughness is powered, that was necessary only for blender 2.7 before they unified bsdf and principled in 2.8. For the same reason we have fresnel power = 2 for glossy and refraction, that we did in 2.7 but was lost with the dual output.
Also in iray the glossy anisotropy affects the refraction roughness. That is, the anisotropy is both on the sutface and the volume, while in blender the anisotropy is only on the surface. So I found the equation below that works fine enough.
# DAZ REFRACTION fac = iray refraction weight # when appropriate we use transparency instead of refraction if iray thin walled == on thin walled = 1 else if iray refraction index == 1 thin walled = 1 else thin walled = 0 # if share glossy input is on then volume and surface share the values # in iray the anisotropy also affects the volume if iray share glossy input == on refraction color = iray glossy color refraction roughness = iray glossy roughness ** (1/(1 + iray glossy anisotropy)) else if iray share glossy input == off refraction color = iray refraction color refraction roughness = iray refraction roughness ** (1/(1 + iray glossy anisotropy)) # please note that refraction ignores the glossy reflectivity # the glossy reflectivity is in the glossy group ior for refraction < 1 ior = iray refraction index # the weighted mode removes glossy layered weight and glossy reflectivity # and the values are maxed out if iray base mixing == weighted glossy color = iray glossy color glossy roughness = iray glossy roughness else glossy color = iray glossy color * iray glossy layered weight glossy roughness = iray glossy roughness # anisotropy anisotropy = iray glossy anisotropy rotation = 1 - iray glossy anisotropy rotations
-
reporter While we're at it I also included the fresnel group inside the glossy group for consistency and some cleanup. Please note that fresnel power = 2. Again we lost this with the dual output.
# DAZ GLOSSY # the weighted mode removes glossy layered weight and glossy reflectivity # and the values are maxed out if iray base mixing == weighted ior = 10 color = iray glossy color else ior = 1.1 + 0.7 * iray glossy reflectivity color = iray glossy color * iray glossy layered weight roughness = iray glossy roughness anisotropy = iray glossy anisotropy rotation = 1 - iray glossy anisotropy rotations
-
reporter - attached daz-weighted.duf
- attached daz-weighted.blend
test scenes for the weighted mode
-
reporter - marked as enhancement
-
repo owner Most things are implemented in the last commit. I didn’t incorporate the fresnel node into the glossy group, since the Fac slot is inherited and cannot be removed without changing the class that glossy inherits from. Which isn’t hard, may do that later.
-
reporter Technically for daz glossy the fac is the color, I mean if the fac is mandatory. We could also have the glossy layered weight as fac to multiply with the glossy color. I didn’t so to get the equations consistent with the refraction group. But it’s not important we can have the fresnel outside it’s just “odd“ to see.
Going to check the new commit ..
-
reporter As for commit f0f4e49 there's a couple of minor issues for the daz refraction.
- The glossy roughness is powered, that was only necessary in blender 2.7.
- If thin walled is on then refraction roughness is set to 0 and ior to 1. This was only necessary before the transparency optimization, now we can keep the iray values.
- If refraction index is 1 we have to set thin walled on, even if thin walled is off in iray. Because ior to 1 means no refraction and we can use transparency.
So please follow the daz refraction equations reported above which fix these issues.
Then below there's a possible setup for daz glossy with fac and embedded fresnel, where we use the color as fac.
edit. As a minor note we could set better defaults for the daz groups. For example ior from 1 to 5 with default 1, instead of no limits. In general I see the limits and default values for the daz groups are not set. You can also reference the blender test scene where I set limits for the daz groups.
Please note that the limits are only to scrub the inputs. One can always enter any value by hand if needed.
-
repo owner These issues have been fixed now, I think. But I’m confused about roughness and powers. There might still be factors that are left over from previous versions. E.g.
Top coat roughness = 1 - iray glossiness**2 (if iray roughness = 0).
Refraction roughness = iray roughness**(1/(1 + iray anisotropy))
Principled roughness = iray roughness * (1 + iray anisotropy)
There are other sockets that could use some limits, e.g.
Fac: 0.0 - 1.0
Roughness: 0.0 - 1.0
Anisotropy: 0.0 - 1.0
Rotation: 0.0 - 1.0
Power: 1 - 4
Thin Wall: 0 - 1Do you think those values are fine?
-
reporter Yes the top coat equation is wrong it probably comes from blender 2.7 when converting the pbr specular/glossiness mode. The other two are right. Those limits are good for me.
# iray pbr specular/glossiness coversion for blender 2.8 and up: iray glossy reflectivity = iray glossy specular / 0.078 iray glossy roughness = 1 - iray glossiness
Going to check the new commit ..
-
reporter Commit b4d0249 is good. Apart that it doesn’t embed the glossy fresnel, and the top coat roughness is wrong as explained above.
-
repo owner Fresnel is now embedded in the glossy group, and limits are set.
-
reporter Commit 9ab6ef4 is good, thank you Thomas for the fast fixes as always. Will leave this open because I want to add support for the principled shader too. But need some tests.
-
reporter UPDATE. WEIGHTED MODE FOR THE PRINCIPLED SHADER
Well it turns out that to get the weighted mode for the principled shader we need three principled nodes. And there are limitations anyway.
The first principled will do diffusion.
The second principled will do the glossy part same as the daz glossy group. Here the glossy color is ignored and we use black instead. But that's expected since the principled shader can't do colored reflections.
The third principled will do the refraction part same as the daz refraction group. Here the transmission color is taken into account. The refraction is then mixed with glossy and feeded to the daz weighted group.
Please note that for the principled shader we use clearcoat to do the thin walled refraction, same as for bsdf we use a transparent shader. So if we need to add a dual lobe or top coat we'll use the relative bsdf groups after the weighted group.
3x principled > daz weighted > daz dual lobe > daz top coat # DIFFUSE PRINCIPLED # assign base color, sss and metallic as usual base color = iray base color .. # reset the specular channels specular = 0 clearcoat = 0 transmission = 0 # GLOSSY PRINCIPLED # reset the diffuse and refraction channels # the principled shader doesn't allow for colored reflection base color = black transmission = 0 # the weighted mode maximizes the specularity specular = 7.5 specular tint = 0 # assign roughness and anisotropy as usual roughness = iray glossy roughness .. # REFRACTION PRINCIPLED base color = iray refraction color transmission = 1 # assign roughness, clearcoat and ior as usual # beware that we use clearcoat for thin walled refraction # please note that in the principled shader anisotropy is only for glossy, not for refraction transmission roughness = iray refraction roughness anisotropic = 0 .. # then we mix with glossy fac = iray refraction weight
Please note that this setup doesn't change when we use the "second principled" option for refraction in the global settings. Since the refraction is already separated so it's the same as the "second principled" option does.
As an alternative, we can use the daz glossy and daz refraction groups for the principled option as well. This way we only use the principled shader for the diffuse part. This has the advantage that the glossy part is better with colored reflections and transmission anisotropy.
This also may make sense since we use the bsdf groups for dual lobe and top coat anyway.
note. In this sense for consistency we may also use a daz refraction group for the “second principled“ option. So instead of “bsdf“, “second principled“, “reuse principled“, we will have “bsdf“, “principled + bsdf“, “principled“. Please note that the second principled option is necessary to correctly handle refraction maps, as explained in
, so the daz refraction group is good and can do the same.#282edit. note. Or we may also eliminate the “reuse principled“ option since it can’t correctly handle refraction maps anyway. And keep the “bsdf“ and “principled“ options where “principled“ uses a daz refraction group instead of the second principled, if there’s a refraction map.
-
repo owner I have been busy recently but hope to find some time to look at this over the weekend.
-
reporter Of course please let me know if something is not clear.
-
repo owner Implemented in last commit. It seems to work quite well as long as the refractive method is set to BSDF. If we use a second principled node, the glossy channel is lost, but I’m not sure if it is worth making it work. It works for opaque materials, though.
-
reporter As for commit ec6143b the principled implementation doesn’t work. You don’t seem to follow any of the setups explained above so I guess I was not clear.
1. The BSDF option already worked fine, the update is for the principled option. We don’t need to change anything for the BSDF option.
2. For principled we can choose between two approaches, either add principled nodes, or add bsdf groups. As explained above. That’s independent from the “second principled“ option, that is, the implementation is the same. Personally I’d go for using the bsdf groups.
3. We may remove the “reuse principled“ option since it cannot handle refraction maps. This option was for “game compatibility” trying to use one principled node by ignoring refraction maps. But since we add dual lobe and top coat as extra nodes anyway, it makes little sense to keep this option.
Actually commit ec6143b seems to use a daz glossy group for the principled option, if there’s no refraction or if “reuse principled“ is set. While it uses a principled refraction with no glossy if “second principled“ is set. This makes no sense with the implementation explained above.
I hope I was more clear please let me know if you need more information.
-
repo owner First, I changed the way to specify material methods. The refractive method is gone, and there are four methods which combine the old opaque and refractive methods:
- Bsdf = bsdf + bsdf
- Principled = principled + second principled
- Mixed = principled + bsdf
- Mixed 2 = Like mixed, except use principled for pure refractive materials (refractive weight = 1 and no texture).
This makes a lot more sense to me than having an option for the refractive method which is ignored if the opaque method is bsdf.
-
repo owner If base mixing = weighted, the bsdf method is now always used for the refractive part. Otherwise it seems to me that we would need yet another principled node for the glossy part.
-
reporter The options for refractive methods were added by user requests, namely @engetudouiti and @Xin iirc. Personally I agree they make little sense at least to me, before we had bsdf and principled as global options.
As to what makes sense we can discuss forever I guess. My original idea was to use bsdf for complex materials “faithful” to iray, to be rendered with cycles. Then principled for “approximated” materials compatible with game engines, thus using a single principled node, to be rendered with eevee. But things went south. First a dual output was added to allow both cycles and eevee to render both methods, on your request. Then “approximated“ methods were added to bsdf on request by Engetudouiti, for speedup. Then “faithful“ methods with multiple principled nodes were added on request by Xin. I was against all of these because I prefer a clean bsdf/principled division, but followed as requested.
I like the new options. Though mixed and mixed 2 can probably be dropped. While a new option “single principled“ would be needed for export to game engines. But I don’t want to add any complexity here so feel free to arrange the material options as you like. At least for me it’s the same for now.
Going to check the new commit ..
-
reporter Commit 810ef01 works fine.
For consistency, since we always use bsdf for the weighted mode, we may as well use bsdf instead of the second principled, the second principled would be replaced by a daz refraction group. Thus mixed 2 would be dropped and mixed would become the principled option. This makes sense since anyway we use the daz dual lobe and daz top coat groups with the principled option.
Please let me know what you think so I’ll mark as resolved.
-
repo owner In the last commit the mixed and mixed 2 methods are removed. The principled method uses the principled node for the opaque part and bsdf nodes for refractive and other parts (dual lobe etc.). If the material is pure refractive (refractive weight = 1 and no texture) the principled node is used for refraction instead.
-
reporter Commit f27dca1 seems good to me.
I like the new division and makes sense to me. We have bsdf for full iray materials for cycles. Then principled with bsdf for refraction, that’s good for eevee and also for a fast cycles, since complex volumetrics is avoided this way, plus this avoids the principled issues with glossy and refraction. Then we have a single principled option for game engines, that will have more limits and we can probably arrange it better in the future, but makes sense for now.
Can’t test all the material features so I trust/hope nothing is broken apart the new division. We can fix bugs if they come out.
-
reporter - changed status to resolved
- Log in to comment
It’s the same as the old specular/glossy workflow that Blender used before the Principled BSDF where you take a Diffuse BSDF and a Glossy BSDF and plug them into a mix shader. In Daz the averaged sum of the diffuse and glossy weights is the factor that controls how much to mix them. 100% diffuse and 0% glossy is wholly diffuse. 0% diffuse and 100% glossy is wholly glossy. 100% diffuse and 100% glossy is averaged out to be 50% of each.