Search Unity

Specular issues using Unity lighting macros?

Discussion in 'PSM' started by coolpowers, Jun 13, 2014.

  1. coolpowers

    coolpowers

    Joined:
    Mar 23, 2010
    Posts:
    125
    I'm seeing incorrect specular lighting with my custom shader, that makes use of the LightingBlinnPhong macro.

    Same code looks fine on every other platform, has anyone seen anything similar on PSM?

    (I can post the shader code but it's a thrown-together mess, so I figure it'd be quicker to see if anyone has already noticed a "gotcha" without poring over code)
     
  2. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    Check the device console log - maybe there is something not supported with your shader, and it's falling back to some other shader?
     
  3. coolpowers

    coolpowers

    Joined:
    Mar 23, 2010
    Posts:
    125
    No errors were thrown up, but I'm now almost positive it was related to my incorrect use of alpha that wasn't affecting other platforms, only showing up on Vita. Changed my shader and everything works fine :)
     
  4. coolpowers

    coolpowers

    Joined:
    Mar 23, 2010
    Posts:
    125
    Actually, to elaborate, there is still something different on the Vita build that I am having to take into account to make it match the other platforms. The Unity LightingBlinnPhong function in Lighting.cginc takes the specular alpha into account:

    Code (csharp):
    1.  
    2. c.a = s.Alpha + _LightColor0.a * _SpecColor.a * spec * atten;
    3.  
    and on the Vita that leads what looks like blown-out specular highlights. I am compensating for this by resetting the alpha in my fragment shader to basically ignore the above calculation.
     
  5. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595