Search Unity

Question GI Lightmap baking for instantiated static geometry/meshes.

Discussion in 'Global Illumination' started by Slight0, Mar 2, 2023.

  1. Slight0

    Slight0

    Joined:
    Dec 6, 2013
    Posts:
    28
    I'm making an "infinite runner" style game where the level generates prefabbed level "blocks" or "pieces" ahead of the player to simulate infinite running. The pieces can be prefabbed before hand. Is it possible for global illumination and reflections to work correctly with the runtime instantiated objects? I've done some searching but only found highly outdated information on the topic.
     
  2. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    324
    In builtin pipeline and URP, we provide roughly 2 options for GI: Lightmaps and light probes.

    You can move lightmapped objects if they are only marked as GI contributors, and not fully static objects. Of course, since lightmaps are just textures, the lighting will likely look wrong if you start moving lightmapped objects, since the texture won't change.

    We currently don't provide any way of moving light probes at runtime. That functionality has been requested quite a few times in the past, and is something we have planned, but I can't give you anything concrete yet. You might still be able to make use of probes if you manage to design the game in a way that doesn't necessitate moving scenes.

    Both lightmaps and light probes have a realtime counterpart, provided via Enlighten Realtime GI. However, Enlighten is also designed around static geometry.

    Baked lighting unfortunately doesn't work very well with prefabbed objects. You'll have to do some manual fixup to make that work. There's a guide here: https://unity.com/how-to/advanced/optimize-lighting-mobile-games#pipeline-light-baked-prefabs, and there are a few community-made solutions floating around. We have on our roadmap to improve the situation: https://portal.productboard.com/uni...-scene-independent-lighting-data-bake-prefabs

    HDRP has some extra GI solutions, such as screenspace GI https://docs.unity3d.com/Packages/c...ion@14.0/manual/Override-Screen-Space-GI.html. Assuming this is for a mobile game, probably not very relevant, though.
     
    Slight0 likes this.
  3. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    324
    As for reflections, you could either opt for something like screenspace reflections, or use reflection probes. As far as I'm aware, you can move around reflection probes and rebake them at runtime as you see fit.
     
  4. Slight0

    Slight0

    Joined:
    Dec 6, 2013
    Posts:
    28
    Thank you, this information is very useful and I'll look at these links more closely.

    A fair assumption, believe it or not this is a sort of "minigame" inside of a larger game that is in fact a desktop game so we are trying to leverage the HDRP first and foremost.

    Given that, do you think SSGI can handle our needs in this specific case? We could use baked lightmapped GI in the other more complex parts of the game, but for this runner aspect the geometry complexity isn't nearly as bad yet we still want reasonable lighting/reflection fidelity for the desired atmosphere
     
    Last edited: Mar 2, 2023
  5. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    SSGI could potentially work well, it all depends on scenario. But it have a cost. If you want to get quality you need to pay for it (i.e 4 / 5 ms on PC). Simplest is to try it. you just have to add a SSGI volume into your game and see if the cost/quality fit your need. Unlike other GI system there is no manual setup for it.