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?
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.
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…