Search Unity

(Beast)Lightmapping plus bumped diffuse plus realtime lights for mobile devices?

Discussion in 'Shaders' started by Axel-F, May 15, 2013.

  1. Axel-F

    Axel-F

    Joined:
    Mar 20, 2009
    Posts:
    224
    Hi,

    I'm getting crazy. ;) I could swear it got it working once, but can not reproduce the right lightmapping and shader setup for my scene. I'm using Unity 4.x Pro with iOS plugin.

    For my mobile device (iPad 2) I want to get a scene with light-mapped, bumped diffuse textures that also take my realtime (point) light into account. This works perfectly with Unitys "Bumped Diffuse" shader. But not with the "Mobile/Bumped Diffuse" shader I want to use. I'm getting a nicely light-baked scene that absolutely ignores my point light.

    Is it possible at all to get realtime - and baked lighting together on mobile devices?

    Thanks for advices!

    Regards, Axel
     
    Last edited: May 15, 2013
  2. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    If you check out the source of Mobile/Bumped Diffuse, you'll see that it only supports one directional pixel light. Normal maps require per-pixel lighting because they define different normal values for every pixel. Remaining lights are rendered per-vertex, and normal maps have no effect there.

    The reason for this is that Unity's lighting pipeline supports only one directional pixel light in the first pass. Mobile/Bumped Diffuse specifically does not support additional passes, which is where additional (non-directional) pixel lights would be rendered.
     
  3. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    If you grab the source to the standard shaders: http://forum.unity3d.com/threads/2085-Builtin-Unity-shaders-source

    Then you can modify Mobile-BumpSpec.shader, and enable support for multiple lights (and lightmaps) by just removing the 'nolightmap noforwardadd'.

    However, multi-pass per-pixel lighting is very expensive on mobile devices - unless you're only supporting the very latest devices, then you'll need to use it sparingly.

    Also, beware that you'll quickly run into precision/range issues. Lights with an intensity above 1.0 don't behave correctly, due to low-precision/limited-range types being used in the shaders. Not yet sure if there's a straightforward fix for that one...
     
    Last edited: May 15, 2013