Mobile Bumped Specular + Lightmap + Bake Only gives Black objects

I am optimizing my scenes for mobile. Changing my directional light to baked only reduces draw calls by 15-20. This is a good saving, so I want to do this.

However, if I use the “Mobile Bumped Specular” Shader and generate a light map, these objects turn black. See the right hand edge of the wall in screen capture.

For the walls, I changed to the “Bumped Specular” shader. These are displaying correctly with the baked only directional light.

A warning is displayed when using “Bumped Specular” and project is targeted at Android “Shader is using white color which does nothing; Consider using Mobile/Bumped Specular shader for performance.”

I want my scene optimized for performance (and size) as I currently get 20 FPS on older devices. So the warning to use mobile shaders has my attention. If it improves performance I want to use it.

My questions:

  1. What is the cost of using “Bumped Specular” over “Mobile/Bumped Specular”?
  2. Why are my objects black when using “Mobile/Bumped Specular” + lightmap + baked only lights?

1746758--110345--LightMapIssue.png

Bump

Bump

If you’re only using lightmaps and have no actual lights, there is no bump or specular to be had.

This is killing us too. The standard bumped specular shader isn’t handling specular and the normals correctly either with directional lightmaps on iOS. We could be doing something wrong, but we’ve been pretty careful.

I’ve been trying to hunt, but the best I could find was a brief mention of gamma vs linear space encoding for Beast lightmaps on mobile. Anyone have any mention of this in the docs? Anyone else actually gotten directional lightmaps to work on mobile with bump and spec?

Ok, that kind of makes sense.

I know next to nothing about shaders. So these are probably dumb questions…

  • I thought lightmap baking captured the lighting from lights tagged for baking. When you run the scene the lightmap is overlayed statically? I take it from your comment that some shaders totally ignore baking, i.e. Bumped Specular?

  • Why does Bumped Specular work with just baking, but Bumped Specular Mobile does not work?

We can’t get bumped specular to even look right when running on iOS. It looks fine in editor.

Spent days on the shaders as of now and lightmapping on iOS appears to be messy business. Directional lightmaps appear as though they aren’t encoded correctly to work out of the box, and the generated shader is inefficient. (We are hand tuning and have gone from 35 to 47 fps on iPad 2, but it’s still not acceptable yet since we are only talking about our environment.) Will keep updating thread as we make discoveries.

If you are doing single lightmaps, a single image in overlayed on top of your existing textures in the scene, then there is no speculars or bumps to be had.

If you are doing directional lightmaps, then there is a a second set of image overlayed that have the direction of the lights encoded and you can have speculars and bump work, but if I remember correctly, not with the mobile Bumped Specular, since that was intended to work properly with realtime lights.

I generally prefer using some sort of bumped/cubemap shader with single lightmaps, which performs better than any specular shader and directional lightmaps. I don’t think there’s such a shader that comes with unity though, but it’s fairly easy to write one.

There was a shadowgun sample scene floating around a while back, I believe it will be worth it to download it and take a cool.

1 Like

This helps explain what is going on: Bumped Specular - Android problem - Unity Engine - Unity Discussions

Mobile/Bumped Specular
// Simplified Bumped Specular shader. Differences from regular Bumped Specular one:
// - no Main Color nor Specular Color
// - specular lighting directions are approximated per vertex
// - writes zero to alpha channel
// - Normalmap uses Tiling/Offset of the Base texture
// - no Deferred Lighting support
// - no Lightmap support
// - fully supports only 1 directional light. Other lights can affect it, but it will be per-vertex/SH.

I think the main differece between the moble and standard shaders is that mobile shaders are vertex lit meaning that light info is calculated on each of the meshes vertexes while the standard shaders are pixel lit where light info is calculated for each pixel of the screen where the mesh is visible. try assigning the standard shader to your objects then bake your lightmap. When thats finished switch it back to the mobile one. But unless you’re using pro lightmaps the normal,spec wont work regardless

1 Like

After wasting 2 weeks trying to attain a similar goal, I just gave up. No matter what I tried I couldn’t get bump mapping and lightmapping to work together.