Search Unity

light.ndotl performance hit on gles2.0

Discussion in 'Shaders' started by dnnkeeper, Aug 30, 2015.

  1. dnnkeeper

    dnnkeeper

    Joined:
    Jul 7, 2013
    Posts:
    84
    I've tried using Standard shader on my Galaxy Note 2 (Mali-400 MP 4 GLES2.0) and got around 13 fps. Pretty poor because I was able to run my old multipass pbs-like shader at 25fps. So I decided to find out what causes such performance hit and discovered that if I comment out NL multiplication in BRDF3_Unity_PBS function I get 21fps!
    Code (CSharp):
    1.  
    2. half3 color = (diffColor + specular * specColor) * light.color// * nl
    3.               + gi.diffuse * diffColor
    4.               + gi.specular* lerp (specColor, grazingTerm, fresnelTerm);
    It causes some artifacts obviously but still pretty good. I wonder how does light.ndotl component gets calculated because it's hidden somewhere in UnityGIInput data.light structure that gets passed to shader internally (I guess). Can we simplify that calculation to get rid of performance hit?
    ( here is my raw test shader which defines custom LightingStandard2 function and UNITY_BRDF_PBS BRDF4_Unity_PBS to override brdf calculation )
     

    Attached Files:

  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    Doesn't that mess up lighting completely? Can't you just not use realtime lights at all for example if you want more performance and just use static lightmaps? (I mean if you are going to break lighting)