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
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Shaders Assetbundles

Discussion in '5.2 Beta' started by KB73, Aug 18, 2015.

  1. KB73

    KB73

    Joined:
    Feb 7, 2013
    Posts:
    234
    Hey folks, sorry to drag up an old thread here. We're still having issues with shaders and assetbundles

    Using 5.x iOS, custom shaders

    We seem to constantly run into problems where the shaders end up being black ( assuming a fallback ) or pink, missing.

    We're loading a streaming scene bundle and loading the level viaApplication.LoadLevelAsync

    My understanding is the shaders are pulled into the scene bundle at asset bundle time?
    This would be the iOS variant of the shader, therefore loading this in the editor means we won't see the right shader?

    To get around this, the common fix appears to be just iterate over materials in the scene and use Shader.Find to reassign the same shader and this seems to rebind/reload the shader correctly from Resources.

    On a device, this same approach is not having an effect / we should not have to do any fix up? We're having a hell of a time trying to identify what the issue is.

    We have tried using ShaderVariants, warming the collection, instantiating prefabs with shaders on them, adding them to the Graphics 'always included' project settings to no avail.

    Are the assumptions above correctly?

    What is the official way we should be adding / using shaders when loading streaming scene assetbundles in 5.x in Unity?

    thanks
     
  2. KB73

    KB73

    Joined:
    Feb 7, 2013
    Posts:
    234
    Problem resolved *sigh*...some shader changes deep down in our includes had changed which caused the issue, apologies for the false alarm. Build is now running again.
     
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I suggest you put all of your shaders into an asset bundle; this will prevent them from being included into each scene, saving you from downloading them multiple times, and allow you to prewarm them all at once.
     
  4. KB73

    KB73

    Joined:
    Feb 7, 2013
    Posts:
    234
    Hey jbooth, thanks for the tip - we had done this already, the other issue was just driving us nuts :) thnx
     
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Sometimes I want to start a support group for people who use a lot of asset bundles. We can sit in a circle, drink coffee, and talk about our problems. Then we can put more stuff into bundles when no one is there to stop us..

    Did it throw build warnings in the logs? We had a lot of issues because failing the asset bundle builds didn't originally cause our builds to fail, so things would slip by. Now I delete the main manifest before the build begins, and check that it's written out afterwards.
     
  6. KB73

    KB73

    Joined:
    Feb 7, 2013
    Posts:
    234
    No errors in the log, it wasn't an issue with assetbundles, just some shader logic that was incorrect. We just missed it in the wee hours. The assetbundle stuff was up in the air on prior versions so it was easy to point the finger initially.