Search Unity

Authoring Lights and Static content with Lightmaps

Discussion in 'Entity Component System' started by Singtaa, Oct 4, 2019.

  1. Singtaa

    Singtaa

    Joined:
    Dec 14, 2010
    Posts:
    492
    Just curious if the upcoming DOTS Sample project will include workflows/support for authoring Lights and Lightmapped Static contents. If not, can anyone provide a rough ETA?

    Thanks!
     
    thelebaron and Orimay like this.
  2. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
    Also very interested in this as well as in DOTS camera.

    My use case takes either moving all the lights and cameras multiple times a frame or having a bunch of them (being rendered in a specific order). So I wonder if Pure ECS solution is coming at some point
     
    Last edited: Oct 4, 2019
  3. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    It is currently not supported. But we are planning to add support for it. I would guess roughly within 6'ish months.
     
  4. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
    Does this also answer my question or only the topic starters one?
     
  5. Singtaa

    Singtaa

    Joined:
    Dec 14, 2010
    Posts:
    492
    I may be completely wrong on this. But I'm guessing lights and cameras have too much dependency with the new SRPs so that it wouldn't make much sense to tackle them into pure ECS until all the other relevant issues (integration between SRPs and ECS) are sorted out, hence the relatively long timeline.
     
  6. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,269
    That's sooner than I would have expected. DOTS and its heavy use of instancing doesn't seem to go along well with lightmapping UVs from an authoring perspective given the current API. Have you thought about using Volume Encoded UVs? I feel like that would be an easier approach given that the UV map would be independent of the entities being lightmapped.
     
  7. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Lights and cameras are totally different from lightmap and lightprobe.
    Lightmap and lightprobe is a much more intrusive change that will take longer.

    Light & Camera is actively being worked on. We are building a system for attaching light & camera components directly to an entity using conversion system. We call this companion game objects. I predict this will land in around ~1-2 months.
     
    Nothke, MasoInar, MNNoxMortem and 8 others like this.
  8. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
    Awesome! Is it gonna be Pure ECS right away or at some point? Would it be possible to set camera rendering order or the render multiple times per frame?
     
  9. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    It's basically a game object with a camera addd to an entity with proper life cycle. So if the entity is destroyed / instantiated it will also be destroyed. This way we don't have to change anything specific for lights & cameras.

    It was very difficult to make an integration for lights & cameras that is maintainable given the amount of properties exposed.
     
  10. Singtaa

    Singtaa

    Joined:
    Dec 14, 2010
    Posts:
    492
    Lights and cameras generally do not need to scale like most other entities, so I'm okay with the Companion GameObjects workflow. In fact, I'm doing the exact same thing in my current ECS project (having systems to handle transforms, lifecycles, and pooling of such GameObjects).

    So one recommendation if I may: have the workflow be flexible enough to allow extra logic on top of the default lifecycles so that stuff like pooling of the GameObjects can be easily implemented by the user if needed. Pooling is just one example; I'm sure there are other needs for managing the GameObjects in specific ways.

    And I'm sure this Companion GameObjects workflow can extend beyond just lights and cameras. It can effectively build a better bridge for transitioning from MonoBehaviour to pure ECS.
     
    Last edited: Oct 5, 2019
  11. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    While that would be nice, pooling is very difficult to make work in such a pipeline given that all properties need to be properly reset since anything can be changed at runtime. We tried this out with the light conversion we have in hybrid renderer now, and it turned out to be both unmaintainable & not performant...

    So Our strategy is to use companion objects for the things that don't happen at scale. Camera, reflection probes, post effect volumes etc...

    Lights are somewhat in the middle, there are definitely games that need 1000's of lights... But its also a lot of effort..

    So as a starting point we use companion objects to just get the workflows going and unblock production and then in the long term we rewrite the handling of lights similar to what we did with RenderMesh, where we plug in at a lower level into unity to get a massive boost in perf & significantly more control... So essentially we take the game object out of the equation for lights completely.
     
    Orimay, Singtaa, thelebaron and 2 others like this.
  12. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Moving UV offset & scale to be an instantiable property is a perfectly good approach. For URP & dots thats a good approach that i have confidence will work very well. It's clearly work to adjust all the pieces to work right with great perf, but we'll do that.

    That said for HDRP the general direction we are actively working on, is to use lightprobes sampled in the pixel shader with multiresolution streamable lightprobe grids. Thats the best way to get quality. On the type of games we want to enable with HDRP & Dots, lightmaps in general is not really a good solution both from artist workflow as well as quality / data storage perspective. If you look at most AAA games, almost everyone is trying to move away from lightmaps...
     
  13. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
    Does this mean cameras are not going to see the Pure ECS light? Or is it just far-far away from happening, but is going to happen? If not, it seems quite sad.

    I am working on portals, that involve some recursive camera render calls. I was hoping it would be possible to just somehow sort the cameras and have them drawn by the camera component system. Otherwise, I guess, I'll get to use a single camera, moving it multiple times a frame to draw all the recursive portals. It just feels slow, but hope it won't be much worse than it would've been if it was Pure ECS. I understand this is a rare use case, and it's not worth devs time at this point.

    You may say that I'm a dreamer
    But I'm not the only one
    I hope someday you'll join us
    And the world will live as one :D

    Besides, I can only wonder what games could have created if it was possible to have tons of high-performance cameras.
     
  14. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Implement portals using multiple Camera.Render calls seems like particularly bad idea in terms of performance... regardless of if that is done with IComponentData or class Camera ...
     
  15. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
    Thank you very much for your response!
    I am sorry for the off-topic, but is there a place where I could get more familiar with detailed difference of camera.Render() vs multiple cameras rendering? It's a surprise to me that camera.Render() does more than multiple cameras do... not this exact thing in a loop to render? I'd love to research this topic deeper.

    Currently, I render the camera manually anyway, since I need it to render into a RenderTexture and apply it over a portal on each iteration (before any other camera render) so that it was visible by other portal cameras (which do manual render as well). The cameras are disabled, by the way.

    I wonder if manual Render of each camera (even if they are disabled and separate) is worse than a single camera teleported or I am just using the wrong approach.

    Edit

    I think I should get rid of the possibility of the portals to render each other from different perspectives and just assign a camera per portal material and use it with no manual render, but still, interested if (and why) manual Render might be a bad thing.
     
    Last edited: Oct 11, 2019