Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Standard shader material directional light reflection creates big white artefacts on iOS

Discussion in 'General Graphics' started by Aberdyne, Apr 30, 2015.

  1. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    I'm trying to create a glass material. The way I configured it is the following:

    Shader: Standard shader (specular)
    Rendering Mode: Transparent
    Albedo: black color with 90 in alpha
    Specular: very dark grey with a value of 35
    Smoothness: 1

    I'm getting something like this on iOS for a nearly flat surface:
    ReflectionWhiteArtefacts.png
    In the editor it shows up as a white pixel at the same average position. The white dot is due to the directional light reflecting off the surface. This dot becomes a blurred disc when you lower the Smoothness value. On iOS a lower value produce the same sort of artefacts even if those are less visible. I first used that as a workaround but it doesn't produce the best effect.

    Is there a way to prevent this reflection dot/spot/disc from happening?

    I have actually got the same result with a non-transparent material some times ago. It seems to be happening every time I use standard shader, but is most visible in the case smoothness is set to 1.

    By the way I'm using Unity 5.0.1, OpenGL in the editor as I'm on Mac OS and OpenGL ES 3 on the targetted device.
     
    Last edited: May 4, 2015
    Ontario likes this.
  2. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    I'm surprised no one had the same issue...
     
  3. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    Without modifying unity lighting pretty much no.
    It's because the sun is treated like a infinitely small light source for specular reflections, this resulting in a dotty reflection. (And often very flickery).
    One way around this is to treat directional lights as a non-point source.
    Another is to clamp glossiness for the BRDF. (While still letting the ambient specular go to perfect sharpness).

    My guess is that most developers/artists simply avoid using so high smoothness values.
     
  4. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    Thank you for your response and sorry for the late reaction. I'm aware most surfaces don't have such smoothness, at least far fewer than we think. In my case though, glass seems to me to be a good candidate. Anyway, I'm not really an expert in shaders... maybe could you give some more directions on how to tinker with BRDF... I'm pretty sure you already have posted some stuffs about that but I can't put a hand on it right now. I suppose I need to create my own shader from the standard one and modify some parts... I'm not sure on how to do it correctly, I'll dig deeper in the forum though! Thanks.

    Oh and I forgot the essential: are you telling me the result I get, shown in the picture above, is to be considered normal? Again this is the result I get on iOS. In the editor it's perfectly smooth, a pixel in the case of smoothness = 1, a smooth disc below... which is perfectly fine. It gives quite similar results (though a little different) until I go below the 0.4 in smoothness (where actually the disc gets totally blurred out in editor).
     
    Last edited: May 9, 2015
  5. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    Umm ok, then no, this is NOT correct!
    I'd have expected this to happen in the .95-1 range...
     
  6. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    To be more complete I've just made a screenshot with other values:
    SmoothnessParamiOS.png

    The setup is simple: a directional light, 5 quads, each having its own material applied with the standard shader (specular setup) (same as above actually) with the indicated smoothness value. Choosing opaque, transparent, changing to standard shader has no influence.
     
    Last edited: May 12, 2015
  7. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    Umm, what comes to mind for me is how your normalmaps look?
    As the size of the highlights isn't that far off. Feels to me more like a broken/bad normalmap.
     
  8. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    Absolutely no normal is used for those tests... even in the real scene. I would be curious to try on another device... but I've only one here.
     
  9. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    I have been getting this same result on all light types on iOS, normal map or not.
     
  10. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    I've submitted that behavior as a bug with Case 697530.
     
  11. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    No news on the subject from Unity. I had sent a bug report and I will certainly redo some test with last version to confirm it's still an issue. I "worked around" the problem by lowering the smoothness but never managed to get rid of it :'( What happened for you @echo4papa ?
     
  12. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    I avoid lights as much as possible, honestly. A single directional light and then let the ambient IBL do it's thing.
     
  13. Aberdyne

    Aberdyne

    Joined:
    Mar 17, 2015
    Posts:
    64
    That's actually what I'm doing but as the directional light is actually the source of those artefacts for me...
     
  14. LeFx_Tom

    LeFx_Tom

    Joined:
    Jan 18, 2013
    Posts:
    88
    Just to make this more current again: I am facing exactly the same issues here, so there hasn't been a fix yet, i believe? Running Unity 5.5, Metal deferred/linear rendering
     
  15. SuperdevUnity

    SuperdevUnity

    Joined:
    Feb 16, 2015
    Posts:
    2
    The same thing appear for us :
    Unity 5.4.4, standard shader on a flat surface, no bump just an albedo map and smoothness to 1 (metallic to 0)
    when we try to do glass or chrome
    Any idea of what's happen ?

     
    Last edited: Feb 13, 2017
  16. samjoly

    samjoly

    Joined:
    Apr 23, 2013
    Posts:
    29
    Same issue on Mobile (Andoird and iOS). Simple scene with a cam, a Directional Light, and a plane with Standard Specular Shader: Specular set to white, and smoothness at 0.9.

    No luck so far.
     
    Ontario likes this.
  17. yoonack

    yoonack

    Joined:
    Apr 29, 2016
    Posts:
    16
    Same issues here on new mobile iPhone X with iOS 11.2. The directional light blob has really weird artifact with standard specular shader with high smoothness value on flat surface. Any ETA on fixing this from Unity?
     
    kenshin and Exustus like this.
  18. Steva

    Steva

    Joined:
    Sep 9, 2010
    Posts:
    60
    We're having the same problem. Any help / workaround would be gratly appreciated.
     
    kenshin likes this.
  19. Steva

    Steva

    Joined:
    Sep 9, 2010
    Posts:
    60
    We've found a solution by forcing float instead of min16float in HLSLSupport.cginc.

    Replace:

    Code (CSharp):
    1.  
    2. #if defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || (defined(SHADER_API_MOBILE) && defined(SHADER_API_METAL) && defined(UNITY_COMPILER_HLSLCC))
    3. // GLES3 and later via HLSLcc, use DX11.1 partial precision for translation
    4. // we specifically define fixed to be float16 (same as half) as all new GPUs seems to agree on float16 being minimal precision float
    5. #define fixed min16float
    6. #define fixed2 min16float2
    7. #define fixed3 min16float3
    8. #define fixed4 min16float4
    9. #define fixed4x4 min16float4x4
    10. #define fixed3x3 min16float3x3
    11. #define fixed2x2 min16float2x2
    12. #define half min16float
    13. #define half2 min16float2
    14. #define half3 min16float3
    15. #define half4 min16float4
    16. #define half2x2 min16float2x2
    17. #define half3x3 min16float3x3
    18. #define half4x4 min16float4x4
    19. #endif // defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || (defined(SHADER_API_MOBILE) && defined(SHADER_API_METAL) && defined(UNITY_COMPILER_HLSLCC))
    With:

    Code (CSharp):
    1.  
    2. #if defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || (defined(SHADER_API_MOBILE) && defined(SHADER_API_METAL) && defined(UNITY_COMPILER_HLSLCC))
    3. // GLES3 and later via HLSLcc, use DX11.1 partial precision for translation
    4. // we specifically define fixed to be float16 (same as half) as all new GPUs seems to agree on float16 being minimal precision float
    5. #define fixed float
    6. #define fixed2 float2
    7. #define fixed3 float3
    8. #define fixed4 float4
    9. #define fixed4x4 float4x4
    10. #define fixed3x3 float3x3
    11. #define fixed2x2 float2x2
    12. #define half float
    13. #define half2 float2
    14. #define half3 float3
    15. #define half4 float4
    16. #define half2x2 float2x2
    17. #define half3x3 float3x3
    18. #define half4x4 float4x4
    19. #endif // defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || (defined(SHADER_API_MOBILE) && defined(SHADER_API_METAL) && defined(UNITY_COMPILER_HLSLCC))
    This is done using Unity 2017.3.1f1
     
    Last edited: Feb 19, 2018