Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Let us know your feedback about the Global Illumination changes in the 2023.2 beta.
    Dismiss Notice
  3. Dismiss Notice

"Scale in Lightmap" only affects baked maps - possible workaround?

Discussion in 'Global Illumination' started by pojoih, Mar 9, 2015.

  1. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    218
    I'm having a scene with very huge objects, but also very small ones which needs more resolution because the player gets very near to them and I've noticed I can't use realtime GI for that because the "scale in lightmap" does not affect the realtime maps :(.

    Any way to get around this? I thought about scaling those objects very big on a invisible layer when baking realtime GI and instantiate them as prefabs on runtime. Does Unity/Enlighten recognize Instances of mesh renderes/filters with different scale and assign the already calculated realtime GI for them?

    EDIT: There could be a way around this with my own Lightmap Parameters assigned to the very small objects but inside of it I cannot crank up the Resolution to more that 100. Why is this restricted?
     
    Last edited: Mar 9, 2015
  2. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    I also noticed that the real time component ignores both the scale in lightmap and even custom lightmap UVs, it always seems to be the same res no matter what you do :(

    Really weird and annoying.
     
  3. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    218
    sadly instantiating a scaled copy of already lightmap static marked geometry isn't working either, there is not realtime GI on it :(.
     
  4. Kuba

    Kuba

    Unity Technologies

    Joined:
    Jan 13, 2009
    Posts:
    416
  5. Kuba

    Kuba

    Unity Technologies

    Joined:
    Jan 13, 2009
    Posts:
    416
    At runtime the objects are matched using IDs (so don't take the scale into account) and not hashes (which when recalculated, would take scale into account). That means that you can scale down your huge objects in the Editor, build lighting and then make the objects bigger again at runtime.
    This of course assumes that there are no non-scaled-for-bake objects affecting lighting on scaled objects.
     
  6. Kuba

    Kuba

    Unity Technologies

    Joined:
    Jan 13, 2009
    Posts:
    416
    This is by design. The reason for this is that objects within one system* need to have the same resolution.
    If "Scale In Lightmap" was used and the user tweaked it arbitrarily and differently on all the objects that would essentially cause each object to go into it's own system. Splitting the scene too much is not great either.

    So instead we put the resolution scale in the LightmapParameters along with other parameters that behave in the same way: all the parameters from LightmapParameters that affect the precompute are hashed and only objects with the same hash can end up in the same system. The intention is that you will just have a handful of LightmapParameters assets in the project.

    *) the grouping of objects that is used to be able to parallelize the precompute

    I'm not sure what you mean here...
    We use the third UV set as the input to Enlighen that's the base for the tweaked per instance UVs. If the third UV set is missing (which is the case for pretty much all the content out there), we use the second UV set (the typical lightmapping UVs, either created by the unwrapper or by you in the modelling package). If this one is not available, we fallback to the first UV set (typically used for albedo).

    In either case, since the realtime lightmaps are typically really low res the UVs need to be tweaked to accommodate additional requirements. The UVs are always adjusted for the current object resolution (depends on the realtime resolution, resolution from LightmapParameters and the world space size of the object) and the hull of each UV island is made to stop at texel centers, so that charts can be packed tightly.

    If "Preserve UVs" is not ticked (the default for all the objects apart from builtin primitives) then the Auto UV algorithm kicks in and tries to simplify the UVs (project charts of geometry deemed insignificant onto other charts).
     
  7. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    @Kuba Firstly thank you for the relatively detailed explanation.

    As for what I meant by custom UVs being ignored by the real time lightmap component, I've taken some screen shots to help explain it.

    This is a pillar type object. I like to use custom lightmap UVs for two reasons. Firstly it lets me hide seams in optimal places, and secondly it lets me assign extremely low resolutions to areas of the mesh that will never be seen by the player (for instance the outside of a wall for an interior scene. This obviously saves texture memory.

    The first screen shot shows the baked lightmap res, you can see that the top of the mesh (never seen by the player) has an extremely low resolution (because it's using my custom made UVs). The second screen shot shows the res for the irradiance channel, which I guess is part of the real time system. As you can see the lightmap res is the same over the entire object. I assume this is because the individual UV islands get re-scaled to a constant work space scale? Or something?

    So anyway, that's what I meant. My understanding of the situation is a little better now. BakedRes.jpg IrradianceRes.jpg
     
  8. Kuba

    Kuba

    Unity Technologies

    Joined:
    Jan 13, 2009
    Posts:
    416
    Ah, yes. Did you try the "Preserve UVs" option in the Object tab of the Lighting window?
     
  9. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Just tried it. Made absolutely no difference.
     
  10. Kuba

    Kuba

    Unity Technologies

    Joined:
    Jan 13, 2009
    Posts:
    416
    Could you submit that scene in a bug report? We'd like to take a look...
     
  11. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Is it a bug? What's the bug?
     
  12. Kuba

    Kuba

    Unity Technologies

    Joined:
    Jan 13, 2009
    Posts:
    416
    Well, it's not really a bug, but more of a use case that Enlighten is not supporting. Having a repro gives us something tangible to talk over with Geomerics.