There is one and only one way of doing that correctly when using the Principled BSDF.
First of all what you should never do is to plug your specular map into the specular input of the Principled BSDF. For reference the original paper: https://media.disneyanimation.com/uploads/production/publication_asset/48/asset/s2012_pbs_disney_brdf_notes_v3.pdf
The specular input is a very poorly named input which if the material is dielectric actually controls the base index of reflection, which means that the specular actually represents the same physical value as the IOR(which however only affects transimission) at the bottom of the shader with the conversion specular = ([ior - 1]/[ior + 1)]^2 / 0.08
.
So for example a specular value of 0.5 will map to an IOR of 1.5.
If the material is metallic also controls the fresnel, (I couldn't find how Principled uses the specular input in the case of metals so please let me know if you find where it is documented), but in the case of metals as long as you don't set specular to 0.0 doesn't produce a significant difference when tweaking it.
So what is the correct way to do it?
The correct way to do it is to convert your specular workflow diffuse and specular maps to the proper metalness workflow maps, before plugging it into the appropriate inputs of the Principled BSDF.
How do you do it?
The first step is to separate create a metallic map from you specular map. If your maps are PBR then there should be a huge difference of the RGB values between the dielectric (usually values ~0.04-0.08) and metallic parts (usually values >0.4) SO to create the metallic map just use a math node set to greater than 0.4. Plug that into the metallic input of the Principled BSDF.
Now we have to make the albedo map from the specular workflow diffuse map, your specular map and the metallic map we just created. For that use a mixRGB node set to mix and use the metallic map as the mix factor. Then plug the diffuse in color 1 and specular maps into color2. If your result is completely black switch your inputs. Now plug that into the base map.
The roughness map and normal maps can be used as normal.
If you have a glossy map just invert the map and you're good to go.
At this point you're pretty much done but you may notice that you can't directly control the reflectance of the dielectric parts, which is the main drawback of the metalness workflow.
However in Blender you can!
Now remember the specular input from before? As it turns out you can actually use it to drive the specular reflectance of the dielectric parts. Doing so however is anything but easy...
First you need to know that your specular map stores what's called F(0) reflectance values. These values can be converted to IOR values, which then can be converted to the specular values Blender's Principled BSDF expects.
The equation governing F(0) and IOR is F(0)=([IOR1-IOR2]/[IOR1+IOR2])^2
. In Blender IOR1 is always the IOR of air(1.00023), which is approximated to 1.0 , so we can simplify that equation to F(0)=([1-IOR2]/[1+IOR2])^2
. Using basic algebra and the quadratic equation we get the identity IOR=(F(0)-1+2*sqrt[F(0)])/(1-F(0))
.
We can now calculate the specular value using the above mentioned equation specular = ([ior - 1]/[ior + 1)]^2 / 0.08
.
Edit: The above described mathematics are correct however I noticed, that when you multiply specular by 0.08 the right sites of both equations are equal, so we get the identity F(0)=0.08*specular
.
You can implement these equations using math nodes.
As the final step use the metallic map you made previously and use another mixRGB node. Plug the metallic map into factor, the value from the math nodes into color1 and put a value of 0.5 into every RGB channel in color2.
Congrats you're done!
To demonstrate everything:
First of all credits to https://www.poliigon.com/texture/metal-spotty-discoloration-001/3225 for providing the free textures.
Metalness workflow:
Albedo map:
Metalness map:
Final render:
Node tree:
Specular workflow:
Diffuse map:
Specular map:
The metalness computed from the node tree:
Final render:
Node tree:
What you may notice is that the final render of the metalness and specular workflows are really... similar.
This is because although the specular workflow gives you more control over the IOR value sof dielectric parts as, the F(0) value is usually between 0.04 to 0.08 you usually won't notice that much of a difference.
What about aliasing? Well I used 4K textures so there is no aliasing with either the specular or metalness workflows. It is true however that with lower resolution textures the metalness workflow shows more significant aliasing that specular one's which is also one of the greatest drawbacks of the metalness workflow.
But if you look very very closely you may notice some aliasing at the borders between metallic and dieletric parts, why is that?
As you can see in my node tree I used a value of 0.2 in my greater than node which is the condition to determine whether or not a material is dielectric or metal. Remember how I said that dielectrics have F(0) values ranging between 0.04 and 0.08 and metals have F(0) values ranging between 0.6 and 1?
So there should be kind of a forbidden zone between 0.08 and 0.6, which are values usually only semiconductors have. However this is only true for the physical properties of materials. When taking a picture we only have a finite resolution, that is a pixel is actually going to cover a whole area of the material. In this area there may be both dieletrics and metals. The F(0) values of the pixel is usually just the average value of these two components weighted by the area of the pixel they cover, which means that even in physically "correct" images we may get values in the forbidden zone. That means finding out what pixel is metal or not is actually always fiddly and sometimes even impossible. You can of course adjust the value in the greater node to have the least aliasing visible.
This issue with the finite resolution of the camera is also why metalness maps have values between 0 and 1. Since the Principled BSDF just lerps between (mixes) two different shaders; one for dielectrics and one for metals, a value of 0.3 doesn't mean that a material somehow something exotic that is neither a metal nor a dielectric. It also doesn't mean that the material is a semiconductor, in fact almost all CG software including Blender ignore the existance of semiconductors.
It actually just means that a pixel is covering 30% metal and 70% dielectric.
Due to the slight discrepancy between the pixels we compute as metalic and the actual metallic values we get aliasing at the borders.
But there is a way to reduce that aliasing drastically! If you have the corresponding metalness map to a set of specular maps you can actually use that instead of computing the metalness, but don't expect the aliasing to go away completely.