Search Unity

How the emission take effect in meta pass?

Discussion in 'Global Illumination' started by watsonsong, Nov 28, 2018.

  1. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    I write my own meta pass and seems the emission filed does not take effect. I select the Emissive mode in scene view after the bake finish, but can not see any color. And I assign a very large value to the emission field seems no any affect to the lightingmap.

    Code (CSharp):
    1.  
    2. MetaInput metaInput;
    3. metaInput.Albedo = brdfData.diffuse + brdfData.specular * brdfData.roughness * 0.5;
    4. metaInput.SpecularColor = half3(0, 0, 0);
    5. metaInput.Emission = surfaceData.emission;
    6.  
    7. return MetaFragment(metaInput);
    8.  
     
  2. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
  3. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    @KEngelstoft , does you mean I add this in my shader GUI:
    Code (CSharp):
    1. materialEditor.LightmapEmissionProperty();
    And I set it to baked:


    And I just mock my meta pass to make sure the Emission is a large red value:
    Code (CSharp):
    1.  
    2. MetaInput metaInput;
    3. metaInput.Albedo = brdfData.diffuse + brdfData.specular * brdfData.roughness * 0.5;
    4. metaInput.SpecularColor = half3(0, 0, 0);
    5. metaInput.Emission = half3(100, 0, 0);// surfaceData.emission;
    6.  
    And I re-bake my test scene:


     

    Attached Files:

  4. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Which version are you using? I fixed a bug in 2019.1.0a1 and wonder if that has made it into the version you are using.
     
  5. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    I find just to the <code>materialEditor.LightmapEmissionProperty();</code> and select it to bake is not enough.
    I have to disable the EmissivelesBlack at the same time.
    In the debug view of the inspector, I change the lightmap flag from 4 to 2, and everything is OK.

    BTW, is there a way I can modify this flag without a custom shader GUI?
     
  6. daville

    daville

    Joined:
    Aug 5, 2012
    Posts:
    303
    I think I'm having a similar problem, I know this is a year old, but could you elaborate a little bit more on your solution, I don't get it.
     
  7. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    The directly method is change the inspector into debug mode, then you can tweak any internal properties. What I do is select the material want to emissive light, and change it's 'lightmap flag' into value '2'.
    Or you can write a custom shader GUI editor to do this.
     
    daville likes this.