Search Unity

Shaders, ShaderGraph and AssetBundles (Script)

Discussion in 'Asset Bundles' started by FranFndz, Sep 5, 2020.

  1. FranFndz

    FranFndz

    Joined:
    Sep 20, 2018
    Posts:
    178
    Simple question,

    Do ShaderGraph, or Shaders have the same rules of no Script inside AssetBundle?
    ShadersGraph nodes are script, so i must have a copy of the shader inside my build?
    If my game have a shader issues, i update the shaders and AssetBundle, i also shoud update my binary as well? So the final user would have to Update the game from the Store and also redownload the game updates?

    I did some test, loading assetbundle and shaders from another project inside my own project (Mobile).

    -Some shaders work normally, they are not inside my build and compile witth no problem.

    -Shader with includes, work normally, even if they are not build in.

    -Shaders using ShaderGraph are always Pink.

    -ShaderGraph with subgroup, they are not collected, i believe that even if the group is not collected wouldnt be a problem as the assetbundle precompile the shader, no? anyways, is Pink.

    -Shader that are build in inside other project compile as pink on my own project, for example, One mesh have a reference for a Build in shader (inside the FBX property), even if the prefab have a material that point to a non build in shader
    prefab A
    -> material -> custom shader
    -> Mesh -> FBX properties -> Lit Shader reference
    = PINK Shader.

    prefab B
    -> material -> custom shader
    -> Mesh -> FBX properties -> delete references
    = OK.

    Any help?
     
    Last edited: Sep 7, 2020
  2. FranFndz

    FranFndz

    Joined:
    Sep 20, 2018
    Posts:
    178
    :(

    will test more shadergraph and assetbundles today.
     
  3. sergiobd

    sergiobd

    Joined:
    May 14, 2014
    Posts:
    37
    Hi Fran! I wonder if you reached any conclusions. I'm building a concept for an app that would use extensively shader graphs and I was wondering if they could be included in AssetBundles!
     
  4. from2001

    from2001

    Joined:
    Oct 5, 2021
    Posts:
    1
    Hi FranFndz,
    Did you try farther more with ShaderGraph and Assetbundle?

    I wonder the results.

    Best,
    Masa
     
  5. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    243
    Bump

    The editor makes it look like Shader Graphs are addressable, but can't see how we could get and use a new one on a built player that wasn't built with it.
    upload_2021-11-5_15-55-10.png
     
  6. DavidJang

    DavidJang

    Joined:
    Sep 14, 2019
    Posts:
    4
    Code (CSharp):
    1. Shader s = assetBundle.LoadAsset<Shader>("xxx/xxx.shadergraph");
    2. someMaterial.shader = s;
    works for me(unity 2021.1)
     
  7. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    437
    not so certain about shadergraph
    however, with shaders in general beyond the main .shader file you would consider including relevant (Drawer files) (Shader GUI files) (.cginc files)

    i would not suspect the any of the graphs would be needed as they should get compiled into the final .shader file. including them may just get blotted memory

    i would be interested to know your results with shadergraph