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. Dismiss Notice

Question What are the benefits to create my own Lighmap UV than let Unity generates it ?

Discussion in 'General Discussion' started by Magnilum, Jan 6, 2023.

  1. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,001
    Assuming you mean invalid texels and not overlap UVs, then that's fine. Maybe what I'm seeing is filtering weirdness and not invalid texels.

    Please post a normal view when you do a bake with filtering off and slightly better settings.
     
  2. Magnilum

    Magnilum

    Joined:
    Jul 1, 2019
    Posts:
    154
    Here are the settings:

    upload_2023-1-7_16-11-35.png

    The result:

    upload_2023-1-7_16-11-55.png

    And the Texel Validity:

    upload_2023-1-7_16-12-26.png
     
  3. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    486
    Why the heck change that :) they would save a ton of wasted space. More so when using their uv2 generator since it's so unoptimized
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,001
    It was for the "bake selected" feature to work better. Then that feature was removed, but the bounding box packing remained...
    Okay, select the material of the tables and check "Double Sided Global Illumination" (or... are you using URP? I seem to recall URP doesn't have this and you have to actually render both faces at runtime for double sided GI to work, which is really stupid)
     
  5. Magnilum

    Magnilum

    Joined:
    Jul 1, 2019
    Posts:
    154
    What does Texel Validity means ?

    It is because I removed the bottom face of my table since it is no visible, it saves som polygone. I did the same with the benches and stools. Is it an error ?
     
  6. Magnilum

    Magnilum

    Joined:
    Jul 1, 2019
    Posts:
    154
    I AM SO FREACKING SILLY.

    I forget to check the static box of my pillars. That is why they did'nt not appears in the backed light.
     
  7. Magnilum

    Magnilum

    Joined:
    Jul 1, 2019
    Posts:
    154
    Now it works so much better, even in Substractive mode:

    upload_2023-1-7_16-26-58.png

    I am going to add the bottom faces of my assets and see if the rest of artifacts will be removed.
     
  8. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,001
    Unity tries to detect if a texel (lightmap pixel) is inside geometry. If it's inside geometry it's "invalid" and as such borrows color from neighbouring pixels.

    The issue they are trying to fix was you would get really dark / pixels / texels in places where geometry overlaps (so a texel that is on the floor inside the pillar for example, would be completely black, and if that texel is a bit visible outside as well, it looks like really strong AO in all the corners, which can look really bad).

    So when Unity sees open backfaces from a certain point, it assumes it's inside geometry. This causes problems when, as you correctly did, people remove faces for better optimisation. The solution is to mark those materials as "double sided for Global Illumination" and then it should work fine.
     
    Magnilum likes this.
  9. Magnilum

    Magnilum

    Joined:
    Jul 1, 2019
    Posts:
    154
    But set it as double sided in the material will make it less performant no ?

    So should I keep it like that or add the hidden face to my meshes ?
     
  10. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,001
    The old built in "double sided for global illumination" made them double sided only for baking. It would otherwise render normally. If URP still forces the rendering and baking to be the same, then yeah it's a bit stupid to have them both on.

    I'm looking it up now, but I don't know if anything has changed on that front: https://forum.unity.com/threads/is-...o-double-sided-rendering.745433/#post-7401089

    A workaround that I sometimes do, is have those "hidden" faces as a separate mesh, that is lightmap static (with scale in lightmap -> 0 so that there is no lightmap space wasted on them) and then also mark them with tag "Editor Only" so that they don't get included in builds. But that may or may not be an over complication of the workflow...
     
  11. Magnilum

    Magnilum

    Joined:
    Jul 1, 2019
    Posts:
    154
    I think I going to add these hidden faces into the mesh. It is less performant in term of polygons but it only adds few one, not thousands one.
     
  12. Magnilum

    Magnilum

    Joined:
    Jul 1, 2019
    Posts:
    154
    Now it is working fine:

    upload_2023-1-7_16-52-44.png

    The only issue is the metallic parts:

    upload_2023-1-7_16-53-20.png

    It works pretty good for the mug but not the clues on the tables and on the ground.

    It should be like this:

    upload_2023-1-7_16-54-24.png

    A bit more shiny. I have added a bunch of reflection probes but it is not very good:

    upload_2023-1-7_16-55-46.png

    upload_2023-1-7_16-56-6.png
     
  13. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,001
    Is the mug set to static? I can't tell if there isn't enough texel density or if the mug simply isn't lightmap static.
    The probes don't look like they are capturing the environment in the image. If you're trying to restore the specular shininess to the screws and bolts, you probably won't be able to do it. Reflection probes can fake specular highlights up to a point, but you do lose specularity when baking lights.
     
    Last edited: Jan 7, 2023
    Magnilum likes this.
  14. DEEnvironment

    DEEnvironment

    Joined:
    Dec 30, 2018
    Posts:
    436
    you may wish to check out the asset called Bakery and it uses Xatlas
    save yourself a lot of pain
     
    Magnilum likes this.
  15. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    486
    Only way to get true specularity is to use a mixed mode light.
     
  16. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    486
    You can use Shadowmasked mode and then you can use Mixed mode lights to get specularity and also realtime shadows from dynamic objects. Just use them sparse, they are expensive.
     
  17. Magnilum

    Magnilum

    Joined:
    Jul 1, 2019
    Posts:
    154
    That is what I thought, and I woulf like to keep it light to be on mobile so I think I will put it away for now.
     
  18. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    486
    If you have smaller rooms with good oclussion you should be able to have a single spotlight mixed mode at least. But like always it needs testing. I wish there was a cheaper way than mixed mode to get specularity.
     
    Magnilum likes this.
  19. Magnilum

    Magnilum

    Joined:
    Jul 1, 2019
    Posts:
    154
    I have something very surprising. On the editor, everything is good as you can see:
    upload_2023-1-8_14-28-40.png

    But when I enter in playmode:

    upload_2023-1-8_14-29-16.png

    The walls stretch out. Do you have an idea of where could it come from ? I use the same material on the floor and I have not the issue.
     
  20. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,001
    Not sure. What shader are you using on the walls?
     
  21. Magnilum

    Magnilum

    Joined:
    Jul 1, 2019
    Posts:
    154
    I am using a lit shader graph for the URP.
     
  22. yackson-cc

    yackson-cc

    Joined:
    May 14, 2016
    Posts:
    46
    Actually, my company is working on a project, and we migrate from UV lightmap unity to own lightmaps, because time imports grows too much time, also we gain a lot of quality, we use this addon to pack Uvs and improve our lightmaps quality:

    UVPackmaster 3 - Blender Market

    Now the entire team open a project in 5 minutes, before this takes 3hours~
    also the light maps looks polished
     
  23. Magnilum

    Magnilum

    Joined:
    Jul 1, 2019
    Posts:
    154
    If I correctly understand, you have replaced the baking of lights in Unity with this tool or at least, a major part ?

    That is awesome !!!

    I am going to open a new thread because I am looking for a way to bake lights at runtime and it seems not imposible but very complicated. I would like to see if there is a way now because the last post dates from 2018.

    I would be interested to talk more about what your team and you have done.
     
  24. James_Arndt

    James_Arndt

    Unity Technologies

    Joined:
    Jan 4, 2021
    Posts:
    17
    Going to chime in and second the mention of Bakery. Not an official endorsement, just my own personal experience with how Bakery improves lightmap bakes and UV generation. Before I was employed at Unity I was actively on these forums asking about the ability to have a flag in the editor for "pass through UVs" for that second lightmap UV channel. Meaning, Unity does nothing to those UVs..no shifting of islands, no packing, no padding adjustments. I recall it was being discussed as an option, but I don't believe it ever made it into our editor. For mobile game development you're generally going to want to author those lightmap UVs yourself. UV islands/isolated shells can contribute to performance overhead if they are numerous. You maximize your texel density and you minimize your UV shells and splits.

    Now this doesn't mean you have to do everything by hand. For my own projects I use a plugin in 3ds Max called UV Packer. https://www.uv-packer.com/
     
    MadeFromPolygons and Magnilum like this.
  25. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    486
    Can't you use your influence to get the workflow better for PLM please :)
     
    James_Arndt likes this.
  26. James_Arndt

    James_Arndt

    Unity Technologies

    Joined:
    Jan 4, 2021
    Posts:
    17
    That is a separate team from my own and I'm not sure I have more influence with their team than any other employee or user. I do have visibility to the work of these teams and I can tell you that many folks here are working diligently at improving these tools and the user's experience. I'm also an indie dev outside of work at Unity and I feel all of the pain points you do. I lean heavily on Bakery for baking lightmaps. I cannot speak about non-public information, but I can say with confidence that these teams are working hard at improving the Unity editor and tools.