Search Unity

LWRP not updating material correctly

Discussion in 'Universal Render Pipeline' started by Unity-Artcraft, Dec 6, 2019.

  1. Unity-Artcraft

    Unity-Artcraft

    Joined:
    Jul 28, 2018
    Posts:
    85
    This is extremely annoying, have to switch to hdrp because the material isn't really updating in lwrp, or particle effects. I activate for example emission and choose white and nothing happens. I have to click on play and exit and click on another material in order to see the change. Same goes with particle effects. Tried on two different new projects ......

    I have unity 2019.2.13f1
    lwrp 6.9.2 and 6.9.0
     
  2. MTandi

    MTandi

    Joined:
    Aug 4, 2017
    Posts:
    10
    I'm having the same issue with URP on 2019.3. I set the emission color, but it isn't updating until I select the object and expand the material.

    Edit: Got it working like this:
    Code (CSharp):
    1. mat.SetColor("_EmissionColor", targetColor);
    2. mat.EnableKeyword("_EMISSION");
    Src: https://docs.unity3d.com/Manual/MaterialsAccessingViaScript.html
     
    Last edited: Dec 10, 2019
  3. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    Hi could you submit a bug for this?
     
  4. Andre_Mcgrail

    Andre_Mcgrail

    Unity Technologies

    Joined:
    Dec 9, 2016
    Posts:
    244
    We have found the issue and fixed it in our master branch, back porting to the 19.3 release branch and will be going out in our next package, hopefully it will land in the 7.1.7 Universal RP package otherwise it will land early next year in the 7.2.0 package.
     
    Unity-Artcraft likes this.
  5. sigil_tech

    sigil_tech

    Joined:
    Sep 18, 2019
    Posts:
    17
    I am having an issue the same as this? Anyone know if this has been pushed? Thank you!
     
  6. Andre_Mcgrail

    Andre_Mcgrail

    Unity Technologies

    Joined:
    Dec 9, 2016
    Posts:
    244
    Unfortunately it did indeed miss the 7.1.7 package, but has been back-ported to a 7.1.8 package that should be releasing next week. Here is the Github PR
     
  7. sschoellhammer

    sschoellhammer

    Joined:
    Feb 15, 2013
    Posts:
    46
    This is still happening on 7.3.1 (unity 2019.3.7f1)
     
  8. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    162
    Yes, you're right. I just did a quick check and I see that this is still an issue for Particle Lit, Particle SimpleLit and Particle Unlit shaders. Thanks for letting us know.

    I've made a PR to fix this and it should be in the next release.
     
    Last edited: Apr 26, 2020
  9. daveGCore

    daveGCore

    Joined:
    Mar 25, 2014
    Posts:
    1
    I'm having the same issue as the original poster - Unity 2019.4.0f1, URP 7.3.1 - any word on this?
     
  10. nobollel

    nobollel

    Joined:
    May 21, 2015
    Posts:
    1
    Have this bug been corrected in recent URP version ?
     
  11. TowerFlare

    TowerFlare

    Joined:
    Nov 12, 2020
    Posts:
    5
    I can't seem to update the my sprite's material at runtime.

    Code (CSharp):
    1. myRenderer.material.color = myColor;
    2. myRenderer.material.SetColor("_Color", myColor);
    3. myRenderer.material.SetColor("_BaseColor", myColor);
    4. myRenderer.material.SetColor("_EmissionColor", myColor);
    5.  
    6. myRenderer.material.EnableKeyword("_EMISSION");
    None of the above work.
     
    Last edited: Nov 18, 2020
  12. TowerFlare

    TowerFlare

    Joined:
    Nov 12, 2020
    Posts:
    5
    There was a suggestion in another thread to change from:

    Code (CSharp):
    1. myRenderer.material
    to:

    Code (CSharp):
    1. myRenderer.materials[0]
    I tried this with all above iterations and this also does not work.
     
  13. DKrayl

    DKrayl

    Joined:
    Jan 12, 2014
    Posts:
    36
    I'm still having this issue in 2019.4.16f1. Was this perhaps fixed in one of the later updates?
     
  14. YuriyPopov

    YuriyPopov

    Joined:
    Sep 5, 2017
    Posts:
    237
    @phil_lira Sorry to necro a old Thread but I'm having the same issue on Unity 2021.2.10f URP 12.1.4 I'm changing a material prop block from a custom timeline playable. Here is the code I use :
    Code (CSharp):
    1.   public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    2.     {
    3.         if (_meshRenderer != null)
    4.         {
    5.             Color color = matPropBlock.GetColor(_EmissionID);
    6.             time += info.deltaTime;
    7.             color = Color.LerpUnclamped(color, _emissionColor, (float)(time /playable.GetDuration()));
    8.             matPropBlock.SetColor(_EmissionID, color);
    9.             _meshRenderer.SetPropertyBlock(matPropBlock);
    10.             _meshRenderer.sharedMaterial.EnableKeyword("_EMISSION");
    11.         }
    12.     }
    The enable keyword "hack" is the only thing that got the material to update.
     
  15. Alberchou

    Alberchou

    Joined:
    Oct 26, 2020
    Posts:
    1
    Having the same issue in Unity 2021.2.17f1 and HDRP/Lit material
     
  16. Adam_is_learning_all_the_time

    Adam_is_learning_all_the_time

    Joined:
    Jun 29, 2016
    Posts:
    12
    Same here in 2022.2.4f1. EnableKeyword("_EMISSION") fixed it, thanks for the info MTandi! :)
     
  17. lightblindor

    lightblindor

    Joined:
    Oct 3, 2022
    Posts:
    3
    This bug still occur in URP lit material of unity 2023.1.6f1, and this solution also works. Thanks!