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

Question How to use Realtime Emissive light from Material on Unity 2021.3.10

Discussion in 'Universal Render Pipeline' started by IdeaLump, Oct 28, 2022.

  1. IdeaLump

    IdeaLump

    Joined:
    Jun 21, 2018
    Posts:
    14
    Hi Folks,

    We are working on a game with a lot of neon lights. And we achieved the effect by baking emissive materials and adding points of lights around these.

    However, in the emission material property, there is a drop list where you can select the type of GI contribution. Baked, Realtime or none. And in the documentation, it is said that if we set it to Realtime, we should be able to illuminate game objects in realtime.

    https://docs.unity3d.com/Manual/StandardShaderMaterialParameterEmission.html
    • Realtime: Unity adds the emissive light from this Material to the Realtime Global Illumination calculations for the Scene. This means that this emissive light affects the illumination of nearby GameObjects, including ones that are moving.

    As you can see in the attached picture, there is no light contribution in the scene from that emissive material.

    Hope there is a work around to make it work, that will help us a lot.

    Thanks
     

    Attached Files:

  2. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    761
    Hi, this "Realtime" mode is for Enlighten (Precomputed) Realtime GI.

    Enlighten Realtime GI supports:
    • Static geometry contribute & receive GI (emissive surfaces illuminate the scene)
    • Dynamic geometry receive GI from Light Probes
    • Dynamic lights (move/change lights, change emission color)
     
  3. IdeaLump

    IdeaLump

    Joined:
    Jun 21, 2018
    Posts:
    14
    Thank you wwWwwwW1 for your answer.

    But still, didn't get how to make it work even by following the documentation. I tried to using Realtime Lightmaps and with use of Light Probes and Reflection probes. Emissive material doesn't seem to be generating light on dynamic objects in realtime.

    I will keep searching...
     
  4. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    761
    Hi, you can try (might not need to do all):
    • Increase the lighmap size of emissive objects.
    • Check Prioritize Illumination under Mesh Renderer.
    • Increase the indirect resolution in the lighting pannel.

    Note:
    1. Only lightmapped objects will contribute to GI. Emissive objects should receive GI from lightmap and have a higher lightmap resolution.

    2. If you need to change the emission color, you should call this:
    Code (CSharp):
    1. // Mesh Renderer.
    2. public Renderer renderer;
    3.  
    4. // An example to update the emission color & intensity (and albedo) every frame.
    5. void Update()
    6.     {
    7.         RendererExtensions.UpdateGIMaterials(renderer);
    8.     }
     
    Last edited: Nov 1, 2022
  5. IdeaLump

    IdeaLump

    Joined:
    Jun 21, 2018
    Posts:
    14
    Done the above and still not able to see the effects on Dynamic objects. But your note intrigued me. When you say "Only lightmapped objects will contribute to GI", you mean also dynamic objects should have real-time lightmap to be able to interact with emissive light?

    If so, should we bake the object and assign a lightmap to it via a shader for example ?

    thank you for your time
     
  6. IdeaLump

    IdeaLump

    Joined:
    Jun 21, 2018
    Posts:
    14
    Btw, Realtime lightmap color from emissive material indeed changes during runtime. It's just that I'm unable to see reflection on a dynamic object from that specific material
     
  7. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    761
    Hi, dynamic objects don't need to be lightmapped.

    They should receive indirect lighting from light probes. DynamicObjects.gif

    Maybe you can check the lightmap (texel) density on emissive (static) objects.

    Set scene shading mode to indirect GI:
    LightmapDebug.png
    IndirectPreview.png

    If the texel density is too low, you may not able to see the emissive lighting on static objects.

    If there are only few sparsely placed light probes in the scene, emissive lighting may not able to illuminate dynamic objects.

    Example (No need to place light probes uniformly):
    LightProbes.jpg

    Note:
    Increasing the texel density may increase the precomputing (baking) time.​

    Never placing light probes inside something like walls. (they will contain "black" indirect lighting, and then provide wrong interpolated results)

    I suggest placing more light probes to areas with strong indirect lighting changes, such as the surrounding of (strongly) emissive objects.​
     
    Last edited: Nov 8, 2022
    IdeaLump likes this.
  8. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    761
    Sorry that I did not explain clearly about when should we call "UpdateGIMaterials()".

    Enlighten (Real-time GI) supports textures (images/videos) as emission source, but will not update them unless we call "UpdateGIMaterials()".

    An example of using textures (images/videos) as emission source:

    Disclaimer: No need to buy this asset store content (and it's not mine), I'm just sharing an example of "UpdateGIMaterials()".


    Hoping this information can be helpful for your project! (Perhaps billboards)
     
    Threeyes and IdeaLump like this.
  9. IdeaLump

    IdeaLump

    Joined:
    Jun 21, 2018
    Posts:
    14
    Thank you so much wwWwwwW1 for your detailed answer.

    The solution was that I didn't have enough light probes in the scene. So when I duplicated them as you set them in the picture you sent, IT WORKED!

    However, It also worked with Baked Emissive. Dynamic objects are also lit by the baked emissive, which means that Realtime emissive is only to be able to change the color when call "UpdateGIMaterials()", right ?

    In all cases, the problem is solved, thank you so much for your help and patience
     
    wwWwwwW1 likes this.