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

Setting Emission colour via Material property block not updating at run time

Discussion in 'Universal Render Pipeline' started by kypo9, Feb 11, 2021.

  1. kypo9

    kypo9

    Joined:
    Oct 5, 2015
    Posts:
    6
    Hey.

    I'm using the default Simple Lit URP shader in Unity 2020.2.2f1

    I'm setting the "_EmissionColor" via a material block (to flash the character red when it takes damage) and can see the change update in the inspector but the character in the game view doesn't change.

    BeforeSeting.png
    AfterSeting.png

    I can see the colour is set in the Frame debugger but i think I'm missing something that perhaps works differently in the URP?

    Update: A quick test doing this via each material and not using the property blocks also caused the characters not to update with the new Emission colour

    Cheers,
    Pete
     
    Last edited: Feb 11, 2021
  2. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,866
    try to switch between sharedMaterial and material in you script
     
  3. kypo9

    kypo9

    Joined:
    Oct 5, 2015
    Posts:
    6
    the use of share material vs material isn't an issue here from having a poke around.

    I narrowed it down to, if the start value is 0 on the _EmissiveColor then it will not update whereas setting the _EmissiveColor to just 1 in value, will make t update correctly. Not sure why but hopefully that helps anyone else hitting the same issue.

    Also, remember that it's HDR so you need to set the _EmissiveColor as a Vector4
     
  4. willowpet

    willowpet

    Joined:
    Jul 26, 2018
    Posts:
    7
    Not the point of the thread, but you're a lifesaver with this tip.
     
    hadynlander likes this.