Search Unity

BUG: Specular Highlights on Mobile

Discussion in 'Unity 5 Pre-order Beta' started by luho383, Feb 9, 2015.

  1. luho383

    luho383

    Joined:
    Dec 2, 2014
    Posts:
    4
    Hi

    attached is an Image that shows the error on Mobile Devices.
    The Image is using OpenGL ES3.0 (iOS Metal does have the same problem) and a Standard Shader.(Specular Setup)
    I think the Render Pipeline uses BRDF2_Unity_PBS for this setup.
    What you can see is the Specular Reflection of a Point Light.

    I have done some research and this line does produce the artifacts:
    Code (csharp):
    1.  
    2. float specular = ((specularPower + 1) * pow (nh, specularPower)) / (unity_LightGammaCorrectionConsts_8 * invV * invF + 1e-4f);
    3.  
    more specific this part:
    Code (csharp):
    1.  
    2. pow (nh, specularPower)
    3.  
    Replacing this with GPU approximation pow(a,b)=exp2(log2(a)*b) does not resolve this. I think the GPU is using it anyway.
    The problem is that when specularPower gets a high value (problem starts at 0.5 roughness or so (specularPower > 1000)) the result of
    pow(nh, specularPower) is not "defined". Sometimes it works, sometimes you get a value of zero. I do not know if it is nh dependent.
    I changed to code to use floats instead of half but that does not make a difference. Is the precision hardcoded in Unity for Mobile? As I would increase this to find out if this causes the problem.

    Can I set the float precision (lowp, mediump, highp) for the builtin shaders? Or better would be a fix from the Unity developers as this happens on Android and iOS, so this should be a problem for many Users.


    Thanks in advance

    Lutz
     

    Attached Files:

unityunity