Search Unity

Emission + Dynamic + GI + Realtime

Discussion in 'Global Illumination' started by ohookins, Oct 15, 2018.

  1. ohookins

    ohookins

    Joined:
    Oct 15, 2018
    Posts:
    10
    Hi, sorry if this has an obvious answer, but I haven't been able to find anything that works.

    A while ago I wrote a custom shader to achieve a certain lighting effect using emission from an object, but never got it working properly with actual emission (only the albedo colour seems to be present). Since reading up more on lighting in Unity I took my test scene back to basics and still can't get even standard stuff working.

    Scene has:
    - cube with standard shader, emitting red light, set to dynamic
    - plane with standard shader, set to dynamic
    - sphere with standard shader set to dynamic
    - realtime GI enabled
    - light probe in the middle of the scene covering all objects
    - no directional lighting, no skybox or ambient light in the scene at all

    Nothing I've tried will get lighting to show up on the plane or sphere in the scene from the emission on the cube. Putting them all into static mode immediately shows emitted light, but in dynamic mode the scene is completely dark.

    No scripts, custom shaders or materials. What am I doing wrong?
     
  2. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    Been a long time since I worked with this, but don't dynamic objects require light probes in order to pick up emission light that is shining? Possibly you need more than one.

    Normally only static objects will receive emission, and that's due to the application of the emission through baking. You didn't mention baking, but I assume you are doing it.

    So depending on how you set this up and what you are doing, there could be issues.
     
  3. ohookins

    ohookins

    Joined:
    Oct 15, 2018
    Posts:
    10
    Well, I do have a light probe in my scene covering at least the emissive cube and the sphere, and part of the ground plane.

    Interestingly, if I select Realtime Global illumination -> Emissive from the Draw Mode dropdown in Scene view, the cube doesn't show up there:

    Screen Shot 2018-10-15 at 20.18.53.png
     
  4. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    I'd say keep playing with it, changing things here and there. That's often the best way to learn. Often it's really simple stuff that causes the problem.
     
  5. ohookins

    ohookins

    Joined:
    Oct 15, 2018
    Posts:
    10
    That's the problem, I feel like I've ticked and unticked every option I can think of. Run out of options now :(
     
  6. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    The manual and the learn section both clearly explain the process of realtime GI in Unity. If you are having trouble with these resources let us know.

    • some static cubes, make one bright red with emission
    • a lightprobe group
    • a dynamic sphere
    • press bake
     
  7. ohookins

    ohookins

    Joined:
    Oct 15, 2018
    Posts:
    10
    Yes, I'm having trouble. I did read through the entire lighting section but somehow it's not clear to me if a dynamic emissive object is even possible with realtime GI. That at least seems to be the result I'm seeing now.

    Unity 2018.2.12f1 on a Mac by the way.
     
  8. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    I just messed with it a little, and it seems your emitter object needs to be light static, even with light probes. Maybe that's the issue?

    Additional things to play with: emission intensity, and placement of the light probes (like, do you have probes between the light and the object to be lit?).
     
    Last edited: Oct 15, 2018
  9. ohookins

    ohookins

    Joined:
    Oct 15, 2018
    Posts:
    10
    Yeah, I just don't know if that's a fundamental limitation of the system? Clearly regular lights can be dynamic and still influence realtime GI. I know about the 4 light source limitation of forward rendering etc, but I only have one light source in the scene - the emissive cube.
     
  10. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    There's no limit to emissive lights with baking. Baking takes each emission source and applies it.
     
  11. ohookins

    ohookins

    Joined:
    Oct 15, 2018
    Posts:
    10
    Well, for the particular effect I was going for with the custom shader, the object also needs to move around, although maybe I can fake it by using a vertex shader and moving the vertices there. Then I could keep the object static presumably.
     
  12. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    lighting.jpg

    I get this scene, using the cube for emission, with only the cube set to lightmap static, a light probe group, and baking. The emission intensity of the cube is 1.1.
     
  13. ohookins

    ohookins

    Joined:
    Oct 15, 2018
    Posts:
    10
    Yes, I also got that effect, but with the static lightmap the lighting will not update if the cube moves, right?
     
  14. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    If you need moving emissive lighting that lights up other objects, you'll need something for dynamic GI like SEGI.

    Basically, baked lighting is "free" because of the precomputing. But if you want dynamic emissive lighting, then you will incur what is essentially the cost of continuous baking.

    SEGI
     
    ohookins likes this.
  15. ohookins

    ohookins

    Joined:
    Oct 15, 2018
    Posts:
    10
    Wow, I'll take a look into that, although it's probably overkill for the small things I want to do. Seeing as what I originally had in mind seems to be impossible I'll look into doing it another simpler way, perhaps with a point light.

    Thanks for your help!
     
  16. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    No problem. While a lot of people use baked light all the time, especially for mobile, it's not a great solution for me. But when you go for non-baked lighting, you either have to go with actual lights - not emission - or something like SEGI. And SEGI requires a modern desktop GPU.

    Does it all pretty much make sense now?
     
  17. ohookins

    ohookins

    Joined:
    Oct 15, 2018
    Posts:
    10
    I guess given that a regular light emits from a single point, and geometry can take on any arbitrary shape, it makes sense that real-time emission from geometry would be difficult to achieve while that geometry is moving. Perhaps the documentation could be clearer around that - probably to seasoned game developers or lighting people it would be obvious due to the complexity, but I'm still learning.

    Thanks again.
     
    hopeful likes this.