Home Technical Talk

[Lightmap UVs] ~ How can I handle a very large asset with very little contiguous surfaces?

triangle
Offline / Send Message
Steamy_Steve triangle
This is the asset I need to bake the lightmap for (the building in the centre):



This thing is 10 meters long, 6 meters wide and 5 meters tall.
Every plank is a separate mesh and there are some details here and there, on the inside....




My issue is that, unless I set the lightmap resolution to a whopping 512px, I always get artefacts.
I've tried re-unwrapping this asset a number of times with a variety of padding values, but there's always some heavy bleeding, with lower resolutions.

This building, including its content, amounts to ~10.5k triangles. Mostly large ones from planks and beams.

I've read a fair amount of articles and forum posts (mostly old or about simple assets), on this subject, and it seems there are only two possible ways to handle lightmap UVs:
A.) you make UE4 or Blender unwrap the UVs automatically, tweaking padding/resolution through a trial and error procedure, or...
B.) you split UV faces manually wherever you have hard edges to avoid bleeding, giving more space to larger surfaces.

Now, this asset alone has over 6k faces, most of which have hard edges.
Do I really have to rearrange 6k faces manually?!
Isn't there some option C, for this poor peon? =(

Help, please! -.-'


Some tech notes:
. the three buildings together use a total of two materials, one tileable for the planks and beams and one atlas for everything else
. planks have no subdivisions and nearly all of them lack the smallest/hidden faces, so they're basically 8 triangles each
. the boat's skeleton cannot be removed from the building and placed as a secondary mesh, because it interacts with the rope, which interacts with the pulley, which interacts with the cart, which stands on wooden rails, which are connected to the rest of the building...or at least I wouldnt know how to do that without having serious issues repositioning the thing in the right spot....and even then, they wouldnt amount to more than about 2k-2.5k triangles, mostly small or insignificantly small surfaces

Replies

  • Eric Chadwick
    Just auto unwrap it. And make sure the uv gutters are wide enough to minimize bleed. And make sure the lightmap baker adds padding in the gutters.

    You can increase the angle threshold for unwrapping more contiguous UV shells. Can reduce tiny isolated shells, but increases distortion. 

    512 is pretty low lightmap for an asset modeled at this resolution. But it really depends on total scene budget, hardware target, etc. 
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    [....]

    512 is pretty low lightmap for an asset modeled at this resolution. But it really depends on total scene budget, hardware target, etc. 
    Thank you for the reply! ^o^

    Well, this is going to be a semi-open-world map, with a relatively wide scenery completely explorable. Much like an arena, but covering about a couple of squared kilometers.
    These three buildings (and the related assets) will make up the "shipyard" area.
    There wont be much more, in its vicinity, thus not much will be loaded along (at LOD 0, at least).
    And the target system is PC.

    I know experience plays a role in learning every skill, but I must ask this question: is there any "rule of thumb", when deciding the resolution of a lightmap?
    This asset alone (the bigger building of the three) has such an amount of exposed surfaces that I'm tempted to set the lightmap resolution to 1024, so to flush away even the very last, small traces of bleeding.

    Let's say the target is a 1GB VRAM system.
    Would 1024px, for such an asset, be that bad?
  • Eric Chadwick
    Usually better to author at slightly higher resolution. Because you can easily scale down as needed. Scaling up is much harder. 

    Can't give you a budget without profiling the game, on target hardware. Complex problem.

    Open world games depend on streaming... dynamic loading & unloading of assets on demand. Highly variable.

    Best bet without that info is to reuse as much as possible.

    Optimize interiors so you can unload exteriors (no see-through cracks in walls!). Use vertex color for baked lighting instead of large memory-hungry lightmaps. Etc. 
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    Usually better to author at slightly higher resolution. Because you can easily scale down as needed. Scaling up is much harder. 

    Can't give you a budget without profiling the game, on target hardware. Complex problem.

    Open world games depend on streaming... dynamic loading & unloading of assets on demand. Highly variable.

    Best bet without that info is to reuse as much as possible.

    Optimize interiors so you can unload exteriors (no see-through cracks in walls!). Use vertex color for baked lighting instead of large memory-hungry lightmaps. Etc. 
    Vertex colour for light baking on an 8 triangles plank sounds improbable.... ^^'

    It's true, this building is kind of "see-through", but there wont be much around.
    And all that's inside can easily be removed in LODs, drastically lowering the amount of polygons involved by at least half whenever you get like 20 meters away.

    This is a very small group, so small I have to handle everything, from design to modeling and texturing. And, in this case, also layout of the area.
    I wish the tech part wasnt on me too, but it seems I'll have to also learn that stage of the pipeline.... ^^'

    Thus....1024px it is?

    Also: why is scaling up things like lightmaps harder than scaling down? =o
  • HAWK12HT
    Offline / Send Message
    HAWK12HT polycounter lvl 12
    general rule I follow, less is more.
    Auto UV generation kinda works best with real time lighting, if you are doing full baked environments its a different story.
    UE4 do thread based storing of lightmaps last I checked so its more prone to baked artifacts in situation where you have two planes side by side with lightmap UV fully covering 0-1 space (or with 4px padding around edges) result will always be a seam in middle unless you up the settings super high for bakes (not lightmap res)

    Your life would be easy if you have your planks unwrapped before instancing to make the barn :D  

    Try hand authoring your UVs with padding and continuous UV shells for planks, give 1 smoothing group per plank and hopefully it ll get rid of your bleed issues.  


       
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    HAWK12HT said:
    general rule I follow, less is more.
    Auto UV generation kinda works best with real time lighting, if you are doing full baked environments its a different story.
    UE4 do thread based storing of lightmaps last I checked so its more prone to baked artifacts in situation where you have two planes side by side with lightmap UV fully covering 0-1 space (or with 4px padding around edges) result will always be a seam in middle unless you up the settings super high for bakes (not lightmap res)

    Your life would be easy if you have your planks unwrapped before instancing to make the barn :D  

    Try hand authoring your UVs with padding and continuous UV shells for planks, give 1 smoothing group per plank and hopefully it ll get rid of your bleed issues.  


       
    I did unwrap the original plank manually, before instancing, which shows if you pay attention to the fact that nearly every single plank has its own unique texture (on a single side of the building, that is).
    I copy/paste'd a UV'd plank over a dozen times, then I've re-unwrapped and re-scaled them all so that each one would show a different part of the texture tile.
    Rotation and further re-arrangement of meshes and UVs dissimulated any noticeable repetition.

    As I said, the building takes about 10.5k triangles, re-authoring the UVs of the whole thing manually would be crazy.

    What I meant with "non-continguous surfaces" is that it's not like unwrapping a column or a box, each plank is a box in itself, hence there's no way to arrange them so that all the faces on the same side of the building would lie close to each other.
    Not automatically, not without placing a seam on nearly every single edge of the structure. Which, by the way, would make the vertex count skyrocket, once in engine.

    I'm not sure about what you mean with "settings super high for bakes (not lightmap res)", but I guess you mean normal maps baking....?
    If that's the case, there's no baking.
    I made the material in Substance Designer, then just spread the UVs around trying to avoid full overlaps so to give each piece a unique look.
    And it kinda worked, if I may say this myself.
    Then I just applied an auto-smooth so that everything that has not a 90° angle gets a smooth look. Which obviously gives planks and beams a sharp shading.

    For the lightmap baking, then, I made a secondary UV mapping for the whole building and auto-unwrapped it leaving enough padding for the choosen resolution while not downscaling pieces to the point some of them collapse to a single vertex.
    Imagine 10.5k triangles in a single UV tile. Even with just 2px of padding, any lightmap resolution below 256x256px would mangle most of the islands into unrecognizable micro-lumps of vertices.

    At 512px it still shows some minor bleeding here and there, thus I'm asking whether such a large asset is eligible for a 1024 upgrade or ignoring the artefacts is a preferable compromise.
  • Eric Chadwick
    I think the unwrap method he was advocating is to stitIch the box sides into a cylindrical like projection, so there's only one long seam on the plank. 

    As you've noticed, lightmapping can be a pain.

    Either redesign the meshes to use larger contiguous surfaces, or use multiple lightmaps per model.

    Open world games require lots of tech workarounds. Not easy. 
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    I think the unwrap method he was advocating is to stitIch the box sides into a cylindrical like projection, so there's only one long seam on the plank. 

    [....]

    Either redesign the meshes to use larger contiguous surfaces, or use multiple lightmaps per model.

    [....]
    "...stitch the box sides into a cylindrical like projection..."? Not clear. =(
    Any tutorial on this subject?

    And....how may I make use of multiple lightmaps for a single mesh?! =O

    Anyway, I said "semi-open-world", but also "a couple of squared kilometers".
    It's relatively small and there are going to be many areas devoid of buildings, just foliage, and nothing GTA-SA or Skyrim sized.
    It shouldnt be too heavy.

    And yes, lightmapping *is* being a pain.... -.-'
  • HAWK12HT
    Offline / Send Message
    HAWK12HT polycounter lvl 12
    https://www.youtube.com/watch?v=BY-nKxyHKRc

    This should get you an idea what we mean  "cylindrical like projection"  
    Its great that you did UV first so I dont see there be a problem to just copy and paste UV1 into UV2 (which is UV1 in game engines, lightmap UV) unless there are overlapping UV then you are in a world of hurt. 

    Also I am wondering why specifically you made gaps in planks of barn, you could make large wall chunks and apply plank texture to make it look like its build with multiple planks and make some gaps in second wall section just to break uniformity. This way you would have saved even more tris and get away with artistic freedom too. 

    Fret not take it easy mate, even AAA studio vets get nightmares :D  

  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    HAWK12HT said:
    https://www.youtube.com/watch?v=BY-nKxyHKRc

    This should get you an idea what we mean  "cylindrical like projection"  
    Its great that you did UV first so I dont see there be a problem to just copy and paste UV1 into UV2 (which is UV1 in game engines, lightmap UV) unless there are overlapping UV then you are in a world of hurt. 

    Also I am wondering why specifically you made gaps in planks of barn, you could make large wall chunks and apply plank texture to make it look like its build with multiple planks and make some gaps in second wall section just to break uniformity. This way you would have saved even more tris and get away with artistic freedom too. 

    Fret not take it easy mate, even AAA studio vets get nightmares :D  


    I know, I could've done something similar to this barrel....




    Or this crate...



    None of those dark lines are actual spaces, just thin faces UV'd over a normal map that resembles a crack. A dark gradient and the illusion is perfect.
    Same for the holes the rope goes through, those are simple flat circles, 10 triangles each.

    But the building is going to be a relevant architectural element, players are gonna fight around and inside of it, thus I decided it would've been cool if they could've spotted each other through the gaps.
    And my everything-director agreed and even praised my design choice.
    Thus there's no turning back.
    There's only regret, now. *dramatic opera music*

    The video you linked aint teaching me anything new, if anything it sounds a lot like the guy is mocking me for having to face something like this....



    This is what a 10.5k triangles building looks like when you try to fit the whole of it into one single lightmap.
    The background is a 128x128 pixels grid I made just to help myself visualize the situation and understand whether I actually had any chance to cram it in such a small resolution.
    The answer is clearly a sharp no.

    It's a no despite my initial effort to minimize the UV cuts so to avoid the vertex count skyrocketing and clogging the engine.

    I guess 512px it is. Maybe even 1024, we'll see.
  • V!nc3r
    Offline / Send Message
    V!nc3r polycounter lvl 8

    I did unwrap the original plank manually
    I can't really seen how you've made the unwrap on your UV layout above, but I suppose the result looks more like the one on the left than the other on my example below, right? Because from your UV layout I can see many tiny islands, but can't zoom enough to know if it's isolated faces or full elements unwraps.



  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    V!nc3r said:

    I did unwrap the original plank manually
    I can't really seen how you've made the unwrap on your UV layout above, but I suppose the result looks more like the one on the left than the other on my example below, right? Because from your UV layout I can see many tiny islands, but can't zoom enough to know if it's isolated faces or full elements unwraps.

    Yep, it's just like the UV on the left of your screenshot. I've unwrapped planks and beams that way to contain vertex count in the engine, this is something I've read and heard everywhere in tuts.
    I've tried Blender's smart UV project function, but it's not so smart since it's basically a planar projection applied according to face normals.
    Which, for instance, leads to curved surfaces staying curved....which take up so much more space than needed, and holes dont get filled.
    An example of this are the boat's skeleton's "ribs", whose front and rear sides form a "U" shape and....well, they stay a "U" shape in the UVs too.



    Furthermore, as you can see, padding seems to affect only the vertical axis. The heck I know why.... =p
Sign In or Register to comment.