Search Unity

Resolved URPMaterialPropertyEmissionColor doing nothing

Discussion in 'Graphics for ECS' started by Naewulf, Mar 30, 2023.

  1. Naewulf

    Naewulf

    Joined:
    Jun 17, 2019
    Posts:
    23
    If I add a "URPMaterialPropertyBaseColor" component with some RGBA values for the float4 to an entity, it works.

    If I add a "URPMaterialPropertyEmissionColor" component with some RGBA values for the float4 to an entity, it changes nothing. It seems like "emission" is disabled somehow.

    What can I do to make the "URPMaterialPropertyEmissionColor" take effect?
     
  2. Naewulf

    Naewulf

    Joined:
    Jun 17, 2019
    Posts:
    23
    Well... in case someone else have problems with this, it seems that even with "emission" enabled by default in the material the override multiplies its value with the base emission. In my case, the default emission color was black, and I was trying to override it with something else. Probably the new color got multiplied with black, which gives no effect to the emission. Changing the base emission to white made the override thing work, that's why I think it's a multiply thing. Don't know if I understood it correctly and if it is a bug or not, because it is my understanding that once you overrride something it should get rewritten, not taken as base for calculations, but it's working now. Sill dont know how to turn emission on and off from code in each instance using ECS like I used to do before, but in that case I just set the emission color to black when I need and it seems to do what I need.
     
  3. Lapsapnow

    Lapsapnow

    Joined:
    Jul 4, 2019
    Posts:
    51
    Thank man! I was going crazy with this... That is pretty dumb, hope they fix it.
    But alright, so, the solution then... is to have whatever material the override happens to be on, also have emission already? Agh. Alright.
     
  4. Selmar

    Selmar

    Joined:
    Sep 13, 2011
    Posts:
    59
    I find it a little odd that for our custom shaders, this does act as an override, but for the URP shaders, it is something like a multiplier.

    I wonder why they behave differently.
     
  5. mingwai

    mingwai

    Small Graphics Potato Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    52
    Looks like it's because if EmissionColor is completely black (0,0,0), the _EMISSION keyword will be turned off by the URP shader GUI, which disables the emission calculation.

    You can workaround by putting a very small value for _EmissionColor so that it's not completely 0. This way _EMISSION will stayed enabled, and URPMaterialPropertyEmissionColor will work.
    upload_2023-6-6_18-19-56.png
     
  6. bnmguy

    bnmguy

    Joined:
    Oct 31, 2020
    Posts:
    137
    So, my materials, even without emission, that use MaterialOverrides look different when the Subscene is open for editing than it does when in play mode. In my case I'm using Shader Graph with HybridPerInstance and just changing the color and metallic value. Seems to look correct in edit mode, but looks wrong in play mode. It kinda seems like a multiplier is being applied to the base?
     
  7. mingwai

    mingwai

    Small Graphics Potato Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    52
    Does it look different in GameView or SceneView?
    The behavior of subscene is like this:
    • if Preference > Entities > Scene View Mode is Authoring Data
      • On SceneView, if you have subscene opened = subscene objects are GameObjects = MaterialOverrides won't work
      • On SceneView, if you have subscene closed = subscene objects are converted to Entities = MaterialOverrides will work
    • if Preference > Entities > Scene View Mode is Runtime Data
      • On SceneView, doesn't matter if subscene is opened / closed = subscene objects are converted to Entities = MaterialOverrides will work
    • For GameView, it is always showing Runtime Data = MaterialOverrides will always work
    • In edit mode or play mode the behavior should be the same
     
  8. bnmguy

    bnmguy

    Joined:
    Oct 31, 2020
    Posts:
    137
    The overrides are being applied in both views (Runtime Data), but look completely different. It is a transparent material though, so maybe that makes it more complex? Not sure. Either way, I can just adjust the look by using the GameView look for now, so not critical but just curious is all. :)

    EDIT
    Okay, so after baking lights, the editor view (runtime data) is good, the game view (not on play) is EXTREMELY bright, and when I go into play mode, it is extra dim. I dunno what is going on, nothing matches at all.
     
    Last edited: Jun 9, 2023
    mingwai likes this.