Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

LWRP shaders cost 80MB size

Discussion in 'Graphics Experimental Previews' started by MetaDOS, Aug 10, 2018.

  1. MetaDOS

    MetaDOS

    Joined:
    Nov 10, 2013
    Posts:
    157
    2 shader of LWRP costs us 80MB, is that expected behavior?
    Screen Shot 2018-08-10 at 7.08.02 PM.png

    Thanks,
    Anh
     
  2. ImbaGame

    ImbaGame

    Joined:
    Jan 29, 2015
    Posts:
    13
    I got same problem, does anyone solve this?
     
  3. Andre_Mcgrail

    Andre_Mcgrail

    Unity Technologies

    Joined:
    Dec 9, 2016
    Posts:
    244
    This doesn't seem too unusual, we have added a few shader variants back in lately, this is the downside of having one 'Uber' shader that attempts to cover everything.

    What would help us though is to get the variant count you are hitting, or even the output of the variants. You can do this by finding the shader(LightweightStandard in this case) in your project window, it'll be under packages if you search for it, then click the drop down arrow by the 'Compiled code', make sure 'Current Build Platform' and 'Skip unused shader_features' are ticked.


    (Example from my project, tbf it doesn't have many materials so it have a very low variant count)
    You will then see the number of variants that are needed for your game, if you click show, a file with a list of variants will be created.
     
    MetaDOS likes this.
  4. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    529
    Last edited: Aug 16, 2018
  5. MetaDOS

    MetaDOS

    Joined:
    Nov 10, 2013
    Posts:
    157
    I'm not sure it's normal. Here is the log on Unity Cloud build:
    2018-08-16_17-04-12.jpg

    It's 32% of the build! And here is the log by manual build on Mac:
    Screen Shot 2018-08-16 at 4.59.19 PM.png
    It seems that the cloud build doesn't strip the shaders?
    Btw, here is our shader usage:
    LWRP_Simple_Lighting.jpg LWRP_Standard.jpg

    Thanks,
    Anh
     
    Last edited: Aug 16, 2018
  6. Andre_Mcgrail

    Andre_Mcgrail

    Unity Technologies

    Joined:
    Dec 9, 2016
    Posts:
    244
    This is interesting, are you sure the build targets/graphics APIs were the same between builds? Going based off what you are getting in the editor vs cloud build it's definitely not lining up, potentially we have a bug there where is it missing the shader stripping process.

    I'll get back here about it once I've learned some more, I'll flag it up with the build team.
     
  7. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    @LeGiangAnh Can you PM me a link to your cloud build project?
     
  8. MetaDOS

    MetaDOS

    Joined:
    Nov 10, 2013
    Posts:
    157
    Done
    The same for all. Actually, I think we cannot make them different?
     
  9. MetaDOS

    MetaDOS

    Joined:
    Nov 10, 2013
    Posts:
    157
    Any update on this?
     
  10. MetaDOS

    MetaDOS

    Joined:
    Nov 10, 2013
    Posts:
    157
    Up, it's over 100MB now
     
  11. MetaDOS

    MetaDOS

    Joined:
    Nov 10, 2013
    Posts:
    157
    It's 210MB now and I'm submitting a bug report with project source. Case 1087483
     
  12. Andre_Mcgrail

    Andre_Mcgrail

    Unity Technologies

    Joined:
    Dec 9, 2016
    Posts:
    244
    Thanks, this is an unacceptably large amount(so is 80 tbf), I will have a look at this today and see if there is something that can be done.
     
  13. MetaDOS

    MetaDOS

    Joined:
    Nov 10, 2013
    Posts:
    157
    Just to remind that this only happens on cloud build. Manual builds work correctly.
     
  14. Frima

    Frima

    Joined:
    Jan 26, 2016
    Posts:
    52
    Found this thread while investigating on that exact issue. Our Lightweight shader is now above 100 mb on unity 2018.2.5f1 android (haven't looked at iOS yet)
     
  15. Andre_Mcgrail

    Andre_Mcgrail

    Unity Technologies

    Joined:
    Dec 9, 2016
    Posts:
    244
    Hey All,

    Just wanting to give an update on this saying that we are still looking at reducing variants where we can, I would like to know what people are experiencing with the newer packages as we have cut down the amount now in 5.2.1 which is the latest LWRP.

    One thing to check is to make sure you don't have any settings enabled on the pipeline asset you are not intending to use, this will add to the combinations of shaders that need to be compiled, also double check if you need all the graphics APIs that are in the PlayerSettings.
     
    Frima likes this.
  16. Frima

    Frima

    Joined:
    Jan 26, 2016
    Posts:
    52
    Thank you for the update! One thing that could be nice is having some kind of detailed size report by shader / variants. It would help a lot to know where / what to tackle first.

    For everyone reading this, please read: https://blogs.unity3d.com/2018/05/14/stripping-scriptable-shader-variants/