Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Mobile Bumped Specular + Lightmap + Bake Only gives Black objects

Discussion in 'Editor & General Support' started by Zaddo67, Aug 24, 2014.

  1. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    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?

    LightMapIssue.png
     
  2. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
  3. tylor_r

    tylor_r

    Joined:
    Aug 18, 2014
    Posts:
    3
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,960
    If you're only using lightmaps and have no actual lights, there is no bump or specular to be had.
     
  5. akutruff

    akutruff

    Joined:
    Jul 24, 2009
    Posts:
    44
    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?
     
  6. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    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?
     
    Last edited: Sep 29, 2014
  7. akutruff

    akutruff

    Joined:
    Jul 24, 2009
    Posts:
    44
    We can't get bumped specular to even look right when running on iOS. It looks fine in editor.
     
  8. akutruff

    akutruff

    Joined:
    Jul 24, 2009
    Posts:
    44
    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.
     
  9. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,960
    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.
     
    Zaddo67 likes this.
  10. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    This helps explain what is going on: http://forum.unity3d.com/threads/bumped-specular-android-problem.271132/

    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.
     
  11. frankrs

    frankrs

    Joined:
    Aug 29, 2009
    Posts:
    300
    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
     
    Zaddo67 likes this.
  12. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,797
    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.