Search Unity

Loading a Material in WebGL breaks the lighting of the Material

Discussion in 'Addressables' started by ErrorX, Apr 5, 2019.

  1. ErrorX

    ErrorX

    Joined:
    May 21, 2014
    Posts:
    22


    As you can see in the video, I have 2 models they both use the same Material.
    If I load the material you can see that the model on the right side has a different exposure.
    This happens in the WebGL build. If I test it in the editor everything works fine.

    This is the code that I use to load the material.

    Code (CSharp):
    1.  
    2. [System.Serializable]
    3. public class AssetReferenceMaterial : AssetReferenceT<Material> { }
    4.  
    5. public class LoadMaterial : MonoBehaviour
    6. {
    7.     public AssetReferenceMaterial AssetMaterial; //I use the same Material
    8.     public Material Material; //I use the same Material
    9.  
    10.     public MeshRenderer MeshRenderer;
    11.  
    12.     //If I set te Material it looks normal
    13.     public void SetMaterial()
    14.     {
    15.         MeshRenderer.material = Material;
    16.     }
    17.  
    18.     //If I load the Material the lighting breaks of the material
    19.     public void LoadAssetMaterial()
    20.     {
    21.         AssetMaterial.LoadAsset().Completed += OnLoadMaterialCompleted;
    22.     }
    23.  
    24.     protected void OnLoadMaterialCompleted(IAsyncOperation<Material> mat)
    25.     {
    26.         MeshRenderer.material = mat.Result;
    27.     }
    28. }
    29.  
    Unity Project:
    https://ufile.io/0prq2

    WebGL build:
    https://ufile.io/5piqp
     
  2. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    There are various problems with materials and lighting and asset bundles from the AAS. Check if this issue persists in 2019.1 and/or 2018.3.12f1. If so use Help > Report Bug to report the bug.
     
    unity_bill likes this.