Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cannot achieve 0% specular with Standard shader in Metallic mode

Discussion in 'General Graphics' started by ArachnidAnimal, Jun 18, 2017.

  1. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,766
    (Using Unity 5.3.6)

    The problem is I cannot get a 0% smoothness when using the Standard Shader in metallic mode, even when the alpha channel of the metallic map contains pure "black" (0 value).
    When switching to Specular mode, I then can then achieve pure blackness.

    The portion of metal is covered in smoke (0 smoothness). But maybe the shader is setting the smoothness to a minimum value? Or is this something to do with fresnel?


    METALLIC MODE
    metalic1.jpg

    SPECULAR MODE

    specular.jpg


    This has had me avoiding the metallic mode and opting for specular mode for this reason alone.

    Am I overlooking something or is this how the metallic mode is supposed to work?

    Edit: looking into this thread: https://forum.unity3d.com/threads/5-3-standard-pbs-is-wrong-cannot-eliminate-remove-specular.375339/

    It was said:
    "In reality everything has specular, F0 is about 4% for non-metals. So that's between 4% and 100% of light going into specular reflection, depending on fresnel effect."


    This is not true. "Vantablack" absorbs 99.965% of visible light.
    source: https://en.wikipedia.org/wiki/Vantablack

    Edit 2:
    According to that thread Unity adds an artificial value of 4% to the smoothness value in metallic mode. That's high considering vantablack only reflects 0.035% of light.
     
    Last edited: Jun 19, 2017
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Smoothness and "F0" light reflectance are totally different things.

    Smoothness is effectively the sharpness of the reflection.

    F0 is the amount of light reflected, and this is usually approximated with the specular color.

    However Aras's original statement is still true, everything has specular, even Vantablack, just very, very little specular. Also your math is a bit off, Vantablack reflects 0.035% of the light, not 0.00035%, but 0.035% would be an F0 of 0.00035. Vantablack is also almost perfectly diffuse, not perfectly smooth. That means, using Unity's Standard Specular shader to replicate Vantablack you should be using a smoothness of 0.0, and a Specular color of 1/255,1/255,1/255 (not 0!).

    But you might say, "wait, 1/255 is not 0.00035!" You're right, it's actually 0.00030353. You probably think it's 0.00392157, but you'd be wrong, because the specular color is defined in sRGB color space, and F0 is in linear space, so the conversion is:

    1 / 255 / 12.92 = 0.00030353

    If you think there should be a power in there, go read up on sRGB.

    Okay, so getting back the main complaint. 99.9999999% of the surfaces in the world fall into that 100%~4% reflectance range (actually more like 90%~4% range, even the best mirrors in the world are only maybe 95%). Yes there are a small handful of natural surfaces that fall below that, maybe down to 3%, but they're very rare. Stuff like Vantablack and the handful of similar man made materials that came before it, aren't like anything that would exist outside of a laboratory ... and in fact Vantablack has to be kept perfectly clean and untouched inside a laboratory or it looses its magical blackness quite quickly.

    So, the Standard shader using the metallic setup is designed so it can closely replicate the specular behavior for the vast majority of non-metal materials on the planet as they actually exist by just setting the metallic value to zero, and if you want something exotic, like Vantablack, or a black hole, you can use the Standard Specular shader.


    Also, to be fair to Vantablack, the newest version is even less reflective, and they've been unable to measure its reflectance, so a specular of 0/255 could possibly be more accurate, but I don't know how low the equipment they're using can measure, could be it's just an F0 of 0.00025 now...
     
    Last edited: Jun 19, 2017
  3. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,766
    Thanks for explaining this. Now it is more clear to me how it works.

    The problem with this is that I'm using the GIMP, and GIMP automatically sets the RGB to 0 when the alpha channel contains 0, so I have to go to 1/255 in the alpha channel to avoid GIMP zeroing-out the RGB.

    So really the specular workflow should be used instead metallic for my situation.

    Thanks!
     
  4. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    Vantablack is not a common material, the recommended value are for common material, vantablack is effectively interpreted as a deep hole by the brain.

    edit:
    Ninja'd
     
    ArachnidAnimal likes this.
  5. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    The metallic workflow work when you have at least two material per objects, that is one metal and one dielectric, you can effectively have one single value per dielectric and only vary the color, it save time, memory and process. Also teh basic value of 0.04 is generally close enough to approximate most material, so people stick to it because there is very minor visual impact.
     
    ArachnidAnimal likes this.
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Yep. Sadly most programs do this, including Photoshop! Most of the time it's not a wrong assumption that everything in the fully transparent areas can be blanked out to a solid color, but for real time graphics you almost always want to retain the color, even when using it for transparency as blanking out the color can lead to fringing when generating mip maps.

    Luckily there's a solution! For GIMP just don't use alpha! I believe you can use a layer mask instead, and make sure to enable "save color values from transparent pixels" in the export dialog for the file format you're saving to.

    For Photoshop you should be using an alpha channel directly instead of layer opacity or layer masks, and never use Photoshop's built-in PNG support. Go get SuperPNG, it's free!
     
    ArachnidAnimal likes this.
  7. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    ArachnidAnimal likes this.