Search Unity

Fragment shader precision mismatch

Discussion in 'Shaders' started by javiermm, Jun 7, 2013.

  1. javiermm

    javiermm

    Joined:
    Jun 3, 2013
    Posts:
    2
    Hello, I'm developing a game for mobile devices and I've found something that doesn't appear to be correct while creating a custom shader.

    The fact is that the same error can be reproduced just adding a Unity plane with a Unity Specular Shader and one light.

    In this screenshot you can see the result in my Mac (In android I get the same result):

    $Captura de pantalla 2013-06-04 a la(s) 14.43.29.png

    Everything is correct. On the contrary, the same escene in my iPad2 renders like this:

    $la foto (2) (1).png

    From my experience with shaders, this generally happens when low precision in fragment shader is selected instead of high precision. So, I can think about three possible reasons:

    - Unity shaders parser doesn't write highp when it generates the native shader that runs on the device.
    - Unity uses some precision pragma directive that the device's driver doesn't process correctly.
    - I don't undestand well the way I can get the correct result.

    Can you help me? Thanks in advance!
     
  2. Lulucifer

    Lulucifer

    Joined:
    Jul 8, 2012
    Posts:
    358
    First ,check the rendering path, forward is produces a more clean result,
    Second ,pull your lights near to the objects, some kind of bands will happen if lights are far away from obj
     
  3. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    You don't have to guess. You can look at the compiled shaders. They're not going to differ between Android and iOS, though, so unless textures are involved (where compression types would make a difference), this just looks like you're rendering to a 16-bit buffer.

    I really doubt highp is going to make a difference over mediump.