Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

2017.4 Broken Lightmapping and Shader Stripping problems

Discussion in 'Editor & General Support' started by bobisgod234, Jun 28, 2019.

  1. bobisgod234

    bobisgod234

    Joined:
    Nov 15, 2016
    Posts:
    487
    Hello.

    We have upgraded our project from 2017.1 to 2017.4, so we are actually on a supported version of Unity.

    Our app uses Deferred rendering, and lightmapping for some scenes. We use Asset Bundles. Our app runs on both Android and PC.

    I have ran into the issue where objects in our scene that are light mapped are being rendered as solid white. As far as I can tell and according to the Frame Debugger, the Standard Shader is writing solid white into RT3.

    Decompiling the asset bundle that contains a material that is on a lightmapped object and looking at the Standard Shader that is built, I noticed that it does not have a "LIGHTMAP_ON" variant of the shader.

    Our scenes are stored in Asset Bundles. The issue only exists if the scenes are loaded from asset bundles.

    So far, I have found that changing the Shader Stripping "Lightmap Modes" from "Automatic" to "Custom" and selecting only "Baked Directional" fixes this issue, but it adds a total of 1gb to the final size of the build. It also causes the program to now take up about 12gb of ram while running (as opposed to the previous 1 or 2gb).

    Adding the Standard Shader to the "Always Included Shaders" list helps, it only adds 200mb to the build size, and takes about 600mb additional ram at run time. However, I cannot run the program on Android at all, it just hangs on a black screen.

    I found this in the log of our android build:

    Code (CSharp):
    1.  
    2. Compiled shader 'Standard (Specular setup)' in 3982.64s
    3.     gles3 (total internal programs: 259392, unique: 105188)
    4. Compressed shader 'Standard (Specular setup)' on gles3 from 719.47MB to 62.57MB
    5. Compiled shader 'Standard' in 3689.35s
    6.     gles3 (total internal programs: 240960, unique: 102948)
    7. Compressed shader 'Standard' on gles3 from 713.61MB to 61.95MB
    8.  
    I don't really understand what would have changed between 2017.1 and 2017.4 to break lightmap rendering like this, and I don't know why not stripping one light map mode causes the shader variant count to blow out of control. I am a bit stuck at the moment solving this issue.
     
  2. bobisgod234

    bobisgod234

    Joined:
    Nov 15, 2016
    Posts:
    487
    Bump. Has anyone seen anything like this? It's completely ruining our 2017.4 builds. I am currently trying some more experiments (such as not putting materials in their own asset bundles) to see what happens.
     
  3. bobisgod234

    bobisgod234

    Joined:
    Nov 15, 2016
    Posts:
    487
    I believe I have fixed it.

    It seems that having a material that is in it's own asset bundle, which is used in scenes that are both lightmapped and not lightmapped, causes Unity to strip the lightmapping shader variants from the Standard Shader that is included in the asset bundle with the material.

    I have worked around this by not adding the materials to their own asset bundles (and adding the textures to an asset bundle instead). Not idea, but it seems to be working.

    I have submitted a minimum-repro to Unity via the Bug Reporter.
     
  4. RDeluxe

    RDeluxe

    Joined:
    Sep 29, 2013
    Posts:
    98
    Hello,

    Could you please link to the created bug report ? So I can upvote it ?

    I've encountered the exact same issue, and it's infuriating. There is nothing in the documentation about this behavior, and it's a pain to track.

    Thanks for your efforts
     
  5. bobisgod234

    bobisgod234

    Joined:
    Nov 15, 2016
    Posts:
    487
    Although Unity were successfully able to reproduce this issue for 2017.4, they closed the case after they asked me to test it in a later version of Unity (I just didn't have the time to do it).

    I don't really understand this (since they were able to repro the issue), but there you go. It probably still exists (at least in version 2017.4).

    I will try to find my minimum-repro project and upload it here if I still have it. Maybe it could be useful for you, if you want to pursue the issue with Unity.

    Sorry I couldn't have been of more help.
     
unityunity