Home Technical Talk

Problem with specular in Unreal Engine 4

Replies

  • ActionDawg
    Offline / Send Message
    ActionDawg greentooth
    UE4 does not use a specular map, it uses metalness which works by storing specular values in the Albedo. The metalness map is a mask that controls a behind-the-scenes blending between a constant specular value and the value in the Albedo (pue black uses the default specular & pure white uses the albedo's value). Then where it uses the albedo value for the specular it removes the albedo contribution. The UE4 specular value does very little and is best left alone.

    It's a less flexible method but saves on texture memory.

    http://www.marmoset.co/toolbag/learn/pbr-practice
    https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/PhysicallyBased/index.html
  • Nyumesis
    Offline / Send Message
    Nyumesis null
    Thanks for your reply and your explanation.
    I guess I had a bug with my Quixel project, because when I tried to export for UE4, it gave me metalness and roughness but also specular map. I did a new project blank project foe UE4, exported it and it's perfectly working now.
    I'm sorry for the inconvenience, but at least I learnt about roughness and metalness more precisely than what I already knew.

    Thank you for your help :)
  • Mant1k0re
    Offline / Send Message
    Mant1k0re polycounter lvl 8
    somedoggy said:
     The UE4 specular value does very little and is best left alone.
    For completeness sake, passing along information on what the spec input in UE4 does:

    "It's used as a masking function on specularity. So it is really a cavity map. Anything above 50% grey gets extra highlights everything below gets AO. "
  • ActionDawg
    Offline / Send Message
    ActionDawg greentooth
    Thanks for the addition, though it's odd how that's worded. What the specular input does is either slightly increase or decrease (to 0) the amount of specular ONLY for dielectrics. The real function is DielectricSpecular = 0.08 * Specular. Resulting in a 0.08 specular reflection for a value of 1, 0.04 for the default value of 0.5 (this is derived from Schlick's approximation for an IOR of 1.5), and no specular reflection at 0. So in a physical sense you're shifting the IOR from ~1.789 to 1.5 to 1.

    This next bit I have to say is just a note on going for the best physical correctness you can in UE4. You can always go with stylizing but understanding how the shading is really done is just as important to that end:

    Material AO is a separate thing entirely in UE4 but is very useful, moreso than I'd argue a cavity map in the specular input is. The problem is that a cavity map makes no physical sense. It's sometimes used to help specular highlight problems, but you can use normal map mip levels to modify roughness (via Composite Texture), which is a physically based way to achieve essentially the same thing. Since it affects roughness mipping it makes asset reflections look consistent as you move towards and away from the object, which is really awesome since it's free. Modifying specular could only exacerbate bright highlight aliasing at a distance, the opposite of what you really want.
    AO on the other hand cannot be generated by the engine on the material scale, but you still want some kind of occlusion to help materials recede properly. While it's not perfectly physical it looks good in practice since it works with the ambient lighting only (another pro over arbitrarily modifying specular). It's also more easily tunable on the fly. So using material AO combined with Composite Texture you can get higher quality lighting with materials that work better at any distance.
  • Mant1k0re
    Offline / Send Message
    Mant1k0re polycounter lvl 8
    Hey doggy :) It's always a pleasure to read one of your post and feel the need for aspirine afterwards!

    I didn't write those words, Radiance did. I have never actually used that output myself, I was just interested in finding out what it does because I saw people plugging specular maps into it and if anything I knew THAT could not be right.

    While Radiance's quote was pretty easy to grasp and explain to other people around me, I am not ashamed to say I have no idea what you mean :) I couldn't even fathom if you're contradicting him or not...
  • ActionDawg
    Offline / Send Message
    ActionDawg greentooth
    Sorry it's confusing. PBR is not so simple when it comes down to the nuance and there's a lot of bad practice. I checked before replying and knew it was Radiance. Specular doesn't affect AO so yes, it's contradicting him on that bit specifically. My post is based off the UE4 source code.

    TLDR; The Specular input handles what percentage of light gets reflected. That percentage only goes between 0% and 8%. It has no effect on metals, and modifying it in a non-physical way is probably not what you want. Composite Texture + Material AO works on metals and does the same thing artists think the cavity map hack does but physically based and far superior in quality.

    Without the math this should be more understandable. Using or suggesting to others a workaround or hack without understanding how it actually affects the shading is bad news bears.
  • Maximum-Dev
    somedoggy, Hi ,

    I usually still multiply AO on top of Albedo for base color and also multiply AO with 0.5 for specular. Mostly for ground materials. (in UE4)
    I would like to hear you opinion on this if possible:

    http://polycount.com/discussion/comment/2480548/#Comment_2480548

    Thanks.
  • Mant1k0re
    Offline / Send Message
    Mant1k0re polycounter lvl 8
    somedoggy said:
    Sorry it's confusing. PBR is not so simple when it comes down to the nuance and there's a lot of bad practice. I checked before replying and knew it was Radiance. Specular doesn't affect AO so yes, it's contradicting him on that bit specifically. My post is based off the UE4 source code.

    TLDR; The Specular input handles what percentage of light gets reflected. That percentage only goes between 0% and 8%. It has no effect on metals, and modifying it in a non-physical way is probably not what you want. Composite Texture + Material AO works on metals and does the same thing artists think the cavity map hack does but physically based and far superior in quality.

    Without the math this should be more understandable. Using or suggesting to others a workaround or hack without understanding how it actually affects the shading is bad news bears.
    Hey, thanks for putting it within my grasp, I really appreciate it. I will be spreading the word around.
Sign In or Register to comment.