Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Missing a shader_feature when I BuildAssetBundles.

Discussion in 'Shaders' started by watsonsong, Jul 29, 2016.

  1. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    I always missing a shader_feature when I build assetbundle.

    My shader and material are located in different assetbundles, and I use BuildPipeline.BuildAssetBundles to build them all. But each time I launch up by asset bundle, the shader sees wrong.

    I dig into the FrameDebugger and find the shader_feature macro is not on, so I change the shader_feature into multi_compile, then everything is OK. It so odd, and I don't want to alway include the feature but want the Unity strip for me. And this keyword is existed in the material in another bundle, I check them existed in debug mode of inspector of that material.

    Then I change to create a material, use that feature, and bundle it into the shader asset bundle, everything correct again!



    I really want to know what the problem of the shader feature and AssetBundles. Is there any log I can turn on to watch how shader variable compile when I build asset bundle?



    Thank you~
     
    jiangzh likes this.
  2. alejandro-unity

    alejandro-unity

    Unity Technologies

    Joined:
    Apr 17, 2015
    Posts:
    7
    I have confirmed with devs that this is a feature that is not implemented yet. The Asset Bundle team is in the middle of refactoring the build pipeline, which will fix this issue.
    For now, the only way that we see is to include all the materials that use a specific shader in the same asset bundle. Alternatively, you could create dummy materials using all the keywords that you need to use.
     
  3. Emericanized

    Emericanized

    Joined:
    Apr 30, 2010
    Posts:
    23
  4. ybelounnas

    ybelounnas

    Joined:
    Nov 25, 2016
    Posts:
    1
    @alejandro-unity Do you have a release date for the new build pipeline?
     
  5. andysaia

    andysaia

    Joined:
    Nov 2, 2015
    Posts:
    21
    @alejandro-unity I'm also looking for an update on this. We're running into this issue on 2017.3.1p1. Adding all the materials into the same bundle as our shaders includes all the textures as dependencies which doesn't work for us. We ship all the shaders in the streaming assets folder and download the textures from AWS.

    Can you expand on the dummy materials option? I tried automatically generating materials per every shader in the bundle and adding all the keywords to this material but the shaders are still getting stripped.