Why can't I get a seamless lightmap even with the most simple geometry?

polycounter lvl 13
Offline / Send Message
TorQue[MoD] polycounter lvl 13
This is something that has driven me INSANE over the past few years working with Unreal Engine. No matter what I do, no matter what tutorial I follow, I cannot get a seamless lightmap. In this tutorial for example the author doesn't worry about grid settings or snapping mesh edges to the seams and yet he gets a perfect lightmap bake. 

Following his example, just with a simple cube wall mesh, these are my results:


Lightmap UVS with plenty of spacing between the islands. Also snapped to the grid lines, though I'm realizing this is mostly pointless.


Very obvious seam between the meshes.


But on the back side of those same two meshes there's no seam.

Is it actually possible to get a completely seamless lightmap on a mesh without a texture?
What am I doing wrong?

Thanks!

Replies

  • Obscura
    Offline / Send Message
    Obscura quad damage
    Try changing the static lighting level scale under the world settings->lightmass. Usually this by itself can solve this certain issue.
  • TorQue[MoD]
    Offline / Send Message
    TorQue[MoD] polycounter lvl 13
    Thanks for the suggestion but adjusting the lighting level scale didn't help at all. It just made the shadows in the corner of the meshes look worse. I set both the smoothness and the level scale to .75 and .5 on two separate builds and neither made the seam disappear. This is why I think it's something to do with the lightmap itself.
  • musashidan
    Offline / Send Message
    musashidan quad damage
    Lightmaps are, and always have been, a nightmare. Sometimes it doesn't seem to matter if everything is set up 100% correct and optimal for lightmaps..........artifacts still remain.

    Thankfully, this horrible aspect of the workflow is on the way out. UE4 just keeps pushing its dynamic lighting quality more and more. DFAO, mesh distance fields, volumetric effects, etc. The gap in quality between baked and dynamic lighting is closing fast. Thank f**k!!

    Edit: just watched this masterclass presentation from the Unreal Dev Day event in Montreal, and the presenter says to use auto-light maps within UE, rather than arsing around in your 3D package with pixel grid snapping and all that other headache inducing messing.



  • melviso
    Offline / Send Message
    melviso polycounter lvl 6
    @musashidan ; I have tried dynamic lighting in the past, late last year. There was a lot of light leaks and it doesn't look as good as baked lighting. Having light leaks, and it's getting tiresome. one should be focusing on getting art done rather than battling with lighting errors for most of the time. I have also followed the pixel snapping and vertex snapping and errors still occur. :- (
  • TorQue[MoD]
    Offline / Send Message
    TorQue[MoD] polycounter lvl 13
    Glad to hear I'm not the only one pulling my hair out trying to get lightmaps to work. The irritating thing is that dynamic lighting is just so much more expensive than static. I wish there was another option like vertex lighting for us to use that doesn't have to rely on lightmaps. The problem with using the build in lightmap generation is that it's usually utter shit. It doesn't understand your geometry so it doesn't always break apart the mesh in the best way which often leads to light or shadow bleed. I'll definitely watch the video though to see if there's some way to get better results out of the auto lightmap system.
  • musashidan
    Offline / Send Message
    musashidan quad damage
     The problem with using the build in lightmap generation is that it's usually utter shit. It doesn't understand your geometry so it doesn't always break apart the mesh in the best way which often leads to light or shadow bleed.
    That's what I always thought and that's why I've always stuck to the lightmapping 'rules'. The guy in the video though specifically says that he and his team never create lightmaps in a DCC, they always do it in-engine.
  • supremedalek925
    Offline / Send Message
    supremedalek925 polycounter lvl 4
    My experience with lightmaps in UE4 isn’t even close to as bad to how they were in UE3, but they can still be a pain. I usually make my own lightmap channel, test both my own and UE4’s automatic result to see which looks better, and raise the lightmap resolution util I get the best result. It can be trial and error.  Also making sure reflection spheres, lightmass inportance volumes, a skylight, and the like are setup is important.
  • TorQue[MoD]
    Offline / Send Message
    TorQue[MoD] polycounter lvl 13
    My experience with lightmaps in UE4 isn’t even close to as bad to how they were in UE3, but they can still be a pain. I usually make my own lightmap channel, test both my own and UE4’s automatic result to see which looks better, and raise the lightmap resolution util I get the best result. It can be trial and error.  Also making sure reflection spheres, lightmass inportance volumes, a skylight, and the like are setup is important.
    It might have something to do with the fact that my project isn't using any textures at all, just simple grey materials, but then again, the video I linked to above isn't using any textures and it looks perfectly seamless. It's also driving me nuts to discover that my meshes are seamless on one side but not the other. It doesn't actually make any sense.
  • TorQue[MoD]
    Offline / Send Message
    TorQue[MoD] polycounter lvl 13
    So interesting, the presenter in that master class video on lighting didn't say they use UE4 to generate the lightmaps, he said that he uses the engine to "Pack" the lightmaps. I wonder if this means that they actually manually create the unwrap in a 3D package and then re-pack the lightmaps with the engine or if they actually do the entire process in engine?
  • musashidan
    Offline / Send Message
    musashidan quad damage
    @TorQue[MoD] I'm pretty sure that what he means by 'unpacking' is actually unwrapping. Maybe a case of lost in translation from French to English? Because you only generate lightmaps in UE. That is, unwrap/pack in one hit. That's my understanding anyway.

    Lightmapping in UE just seems completely non-sensical and random to me. Your most basic of examples above is case in point: You have followed the rules and SHOULD have zero artifacting, yet..........

    Makes no sense, really.

    And while dynamic lighting is still expensive and not as rich as static baked it's very much a problem still being resolved, I believe that Epic are making great progress on this 'holy grail' and it's only a matter of time - hardware evolving all the time and always getting cheaper - before we can finally give a big finger to lightmapping altogether.
  • harry1511
    Offline / Send Message
    harry1511 polycounter lvl 5
    @TorQue[MoD] In one of the streams, Epic guys did address your problem. You can crank up the Indirect Lightning Quality and lower the Indirect Lighting Smoothness. This will increase the build time, but at least somewhat cure the problem. It's not a 100% perfect because you still get the seam or artifact.

    The reason is each mesh is sent to to different CPU thread, so when they get the indirect lighting, the first mesh doesn't know the light information from the 2nd mesh sitting next to it, thus you get the seam.

    If you don't need super modular level, then they recommend to build each of the room's walls as one piece to prevent seam. Of course like you may already know, textures will help.
  • TorQue[MoD]
    Offline / Send Message
    TorQue[MoD] polycounter lvl 13
    harry1511 said:
    @TorQue[MoD] ...If you don't need super modular level, then they recommend to build each of the room's walls as one piece to prevent seam. Of course like you may already know, textures will help.
    This is hitting the nail on the head. I prefer to make modular assets as you get a lot more use out of them, but for my own sanity, I've decided that it's much better to work with more one shot assets. Now I know why so many games don't go completely modular. 
    I'm going to start using brushwork a lot more. It's not as easy to work with as meshes, but it doesn't come with any of the lightmap issues and you can use a much lower lightmap res and still get decent results than you can with large static meshes it seems.

    Also, I did try increasing the lighting quality and lowering the smoothness but I couldn't find a setting that fixed the seam. It only seemed to make things worse.

    And that sounds like the worst method for rendering the lighting but I guess they decided to sacrifice quality for performance. Oh well. I'm going to look into the Mesh Distance fields and see if I can get some better performance with those. When I did my dynamic lighting tests it was before this feature was implemented.

    Thanks for all the feedback and discussion everyone!
  • TorQue[MoD]
    Offline / Send Message
    TorQue[MoD] polycounter lvl 13
    So I tired taking the advice of the Author of that UE4 lighting master class and using the engine to generate my lightmap UVs... Now I've got the error "Vehicle_Van_1A Lightmap UV are overlapping by 3.4%. Please adjust content - Enable Error Coloring to visualize."

    God damn I hate lightmaps!
  • musashidan
    Offline / Send Message
    musashidan quad damage


    God damn I hate lightmaps!
    You are not alone, brother.

    Have you seen this one?

  • TorQue[MoD]
    Offline / Send Message
    TorQue[MoD] polycounter lvl 13


    God damn I hate lightmaps!
    You are not alone, brother.

    Have you seen this one?...

    Oh man! Every bit of info about lightmaps conflicts with each other. I was told previously to go with non-contiguous islands. That each surface that was going to have a potentially different lighting scenario on it - For example two right angle sides of a cube - should be separate in your lightmap otherwise you risk bleed. Now this video says to keep them mostly contiguous. Grr!

    It's nice to learn about lowering the min lightmap res can increase the padding between the islands though... that will probably fix the overlap by 3% issue I was getting.
    Thanks for the vid Musashidan
  • musashidan
    Offline / Send Message
    musashidan quad damage
    Yeah man, that's exactly what I thought too. Did you get the non-contiguous islands idea from the World of Level Design tutorial? I actually used to unwrap contiguous until I watched that. Now it's back to contiguous. I cn't believe it took Epic this long to bring out a video on this stuff, clarifying some of the mystery/guesswork behind lightmapping.
  • musashidan
    Offline / Send Message
    musashidan quad damage
    @TorQue[MoD]  Well, after some more digging around I came across something that I haven't seen before(in the many, many threads and vid tuts I've read/watched on lightmaps) It turns out you're not crazy after all. :) This explanation from Epic pretty much wraps up this mystery. It's pretty shit but at least you can move on and not waste any more of your time trying to fix the unfixable.....



    Often when you build lighting for your project and in indirectly lit areas you may notice that there is sometimes a shading difference between modular planar surfaces, typically walls, floors, and ceilings. This is an unfortunate side-effect of how static indirect lighting is handled at the moment and doesn’t have an easy way to fix. This can hopefully be made better in the future.

    Here’s the breakdown of the issue, if you’re not familiar.

    • Light hits a surface and then that light is bounced on the surrounding surfaces. This type of bounce light is referred to as Indirect Lighting. Some surfaces will be directly lit as well while still receiving some bounce, like the Wall that is partly lit fully and has some indirect lighting with the shading issue in the shadowed corner.
    What’s happening here is that each of these static meshes are sent to the CPU to be processed in the order they are received and on different CPU threads. This simply means that while each one has their lighting built by lightmass the others don’t know what the shading for the one before it would look like to reference the edges to make sure they match up. This leads to slight shading differences between each planar surface.

    So, by now, you’re wondering “What can I do about this?!”, right?

    In the World Settings under the section for Lightmass you can adjust some of the settings here to get better results.

    • Indirect Lighting Quality can be set to 2 or higher.
    • Indirect Lighting Smoothness can be set to usually a range of .65-.75. The lower the value here is though the more artifacts you can run into that make the lightmap look like it has blotchiness to it.
    • (Recommended only for Advanced Users!!) Static Lighting Level Scale can be adjusted to a lower value to get better blending as well. But this changes the scale of how lighting is calculated for the entire level. This will increase build times significantly if the value is lowered but will give you better results. This is commonly used by those within the Architectural Visualization field and not by those developing games unless they have a specific reason and understand the choice.

    When you adjust the quality of indirect lighting it’s always a good idea to lower the lighting smoothness to get better results. This helps blend better between these surfaces, but it doesn’t necessarily help remove the issue completely and can have other side-effects as well. You should really test it in project or a test map to fully understand what you’re adjusting here and why.

    There is also some steps you can take to reduce how noticeable this artifact is and steps you can take with the design of your project.

    • Try not to over-modularize your levels! This is important. You may think that making a moderately sized wall into nice smaller concise pieces that you can pack together like Lego’s is the best thing ever, but you run the risk of this shading difference happening, and you now have many more actors that add to draw calls and checks for the visibility states of these. It’s best to have have a single wall when it makes sense rather than many small pieces. You get reduced draw calls and less issues that can occur with lighting.
    • You can simply use other geometry to better hide these pieces where there would be seams, like columns or adjoining walls, or wall molding.



  • TorQue[MoD]
    Offline / Send Message
    TorQue[MoD] polycounter lvl 13
    You know I think I'm going to look into the dynamic lighting that they developed for Fortnite and see if maybe that can increase the performance while also allowing me to drop the static lighting entirely. It's just not worth the struggle.

    I love how everything you hear about the engine is in conflict with each other. Now he's saying NOT to use modular meshes because it increases draw calls. I thought the whole point of modular pieces was that the engine's instancing system makes them a single draw call to improve performance?
    And then if you're using one mesh, you need a much higher lightmap resolution to get the same shadow quality. Urgh!
    My god I really wish Valve would release Source Engine 2! lol

    And yes, the non-contiguous islands idea was from the World of Level design but I think they also suggested to in the official documentation somewhere as well if I'm not mistaken.


  • musashidan
    Offline / Send Message
    musashidan quad damage
    Yeah man, dynamic lighting is what I've been using for a while now. It has really been improved and optimised. Just think about it.....you NEVER have to deal with lightmaps again!! Not to mention all those hours spent building lightmass.....

    Something I found out that is definitely worth a look is Light Propagation Volumes. Strangely, it's not on by default and you have to add r.LightPropagationVolume = 1 to an .ini file.

    You can also use DFAO on your skylight in conjunction with it. And mesh distance fields on a per-mesh or global scale.

    Find out more here https://docs.unrealengine.com/en-us/Engine/Rendering/LightingAndShadows/LightPropagationVolumes

    It's funny, but the instances conflict is exactly what i said aloud as I read it. I call bullshit, though. Instances do not add draw calls. The mesh/textures/material is called once. Otherwise it wouldn't make any sense.





  • PixelMasher
    Offline / Send Message
    PixelMasher quad damage
    keep in mind with unreals auto generate lightmap uvs, its not actually doing an unwrap, its taking the UVs from channel 1 and repacking them at a consistent texel density. so if you have stitched/overlapping stuff going on in channel 1 it will carry over to your lightmap and you will get that overlap error. you can do a quick lightmap uv in max/maya, and then in unreal set the source lightmap channel to channel 2 and have it create its own lightmap layout for you. 

    Ive found that grid snapping uvs and setting the static lighting level scale to something like 0.2 can help when I was doing a test on using a bunch of square pieces to make a single wall, but thats pretty in efficient anways, going too modular like building a 10m wall out of 2m pieces is just pretty bad practice. your object count will skyrocket (not drawcalls) and its a pain in the ass to work like that, I would just create 2-3 modular pieces of larger sizes, like a 5m and a 10m piece. it takes barely any extra time and you will have less seams and weird lighting issues.

    when you are grid snapping uvs, make sure your UV grid is set to the actual intended lightmap texture size like 32 as then each grid point will actually represent a pixel. if your grid is randomly set to like 128 and you are using a 32 lightmap, chances are your uv seams are still in the middle of a pixel, which gives you those seams. Give your wall pieces actual thickness it will help with light bleeding A LOT. dont use flat planes for walls in unreal, especially with modular square pieces like your setup. also, if you are snapping your uvs, you have to disable auto generate lightmap uvs and probably re-import your mesh into unreal.

    also, unless you have a super clean look like mirrors edge with very minimal diffuse and normal detail, shading errors like that wont be too apparent, little seams disappear when you have a brick texture or something with detail on it. Here is a quick example scene I whipped up to replicate your modular setup. EVERY LIGHTMAP IN THIS SCENE IS SET TO 64PX. the walls and ceiling are the same 4m piece that has backfaces and 0.5m thickness to it. so a 64 lightmap evenly distributed over that entire mesh surface area, including the backfaces you never see. so the faces you see really only have about 32px of lightmap space. up close you can see a tiny seam in some spots, but at an actual realistic camera/gameplay distance you will never notice it. I would say those lightmaps would realistically be set to 32 or 16 in an actual production, maybe even 8.

    again, setting up your envronments using a ton of square pieces that have random seams on flat surfaces isn't really great, its much better to have natural seams between pillars or trims/details. building stuff like this is how bad "level designer art" looks alot of the time. it feels flat, square and grid snapped.




    rarely is increasing the lightmap size going to improve your problem past a certain point. having everything set to 256-1k lightmaps isn't really a realistic option and will make professional lighting artists laugh. Indirect lighting really requires very low lightmap sizes, only stuff with direct shadows does bumping up the LM res help.  In the unreal lighting academy vids on youtube (well worth a watch) the dude from DICE talks about how for most of their lightmaps they have a density of about 1-4 pixels per meter, with some huge walls having a lightmap of about 16 depending on the situation. TONS of info and bug fixing in this video (the battlefront 2 lightmap size stuff is at 16 mins) cranking your lightmap sized wont do much in most cases, other than quickly quadruple your build times.


  • musashidan
    Offline / Send Message
    musashidan quad damage
    @PixelMasher thanks for the input. Just wanted to get your thoughts on the 'UE adds a 1 pixel border pad around your lightmap sheet' thing. So many people advise to snap your UVs to a grid 2x2 pixels smaller in dimension in your DCC - so if your intended res is 32 then the grid becomes 30, 64 beomes 62, etc.

    Regarding the solid modular geo, do you ever just use giant solid mesh light blockers? For instance on a sci-fi hallway the wall/floor/ceiling will have a lot more detail than a flat plane.

    Do you think that dynamic lighting in UE4 will some time in the near future replace static lighting in both quality and performance overhead?

    Do you ever scene-bake lighting in Max/Maya using offline rendering like Vray? I know that this is a big part of Mobile or even VR, but PC/console? Something like the Amplify Creations Multi-UV Bake Tool

  • PixelMasher
    Offline / Send Message
    PixelMasher quad damage
    @PixelMasher thanks for the input. Just wanted to get your thoughts on the 'UE adds a 1 pixel border pad around your lightmap sheet' thing. So many people advise to snap your UVs to a grid 2x2 pixels smaller in dimension in your DCC - so if your intended res is 32 then the grid becomes 30, 64 beomes 62, etc.

    Regarding the solid modular geo, do you ever just use giant solid mesh light blockers? For instance on a sci-fi hallway the wall/floor/ceiling will have a lot more detail than a flat plane.

    Do you think that dynamic lighting in UE4 will some time in the near future replace static lighting in both quality and performance overhead?

    Do you ever scene-bake lighting in Max/Maya using offline rendering like Vray? I know that this is a big part of Mobile or even VR, but PC/console? Something like the Amplify Creations Multi-UV Bake Tool

    For the lightmap uvs I just left at least 3-4 grid points around the border and 2-3 between the shells, i didnt even focus on maximizing the lightmap uv space, just that the edges were on grid points and there was a bit of padding around everything. when its all said and done, the uvs probably are around 70% of the space without padding. 

    modular geo with more detail, yea you could have separate light blocker geo, or you could just make a super cheap side and back of that modular mesh for the sides you will never see. it wouldn't be super expensive to have an extra 50-100 tris and it solves problems as you go, just dont have backfaces where light can shine through even if you use a 2 sided material.

    in terms of dynamic lighting in unreal, its already pretty decent. I think a lot of people think its a lot more expensive than it actually is. as long as you dont have a ton of shadow casting lights or tons of overlapping medium sized lights, you can go pretty wild. for portfolio stuff I wouldnt worry about how "expensive" your lighting is, especially if you are not actually going to be a lighting artist. chances are whatever you come up with would be fine. God of war uses a ton of dynamic lights and it runs pretty damn well on consoles. A dynamic/stationary light for the sun is pretty much standard in most modern games anyways. you just lose a lot of the gorgeous GI you get with baked lighting. thats why some games like the last of us and uncharted bake their bounce lighting/ambient and use a dynamic for the sun etc.

    as for baking in max/maya and trying to transfer all that over? hellll no, lightmass gives pretty amazing results and is more than enough for most artists. The technical headaches of trying to transfer all that stuff over is a huge time sink and not something the average artist should be doing. If you cant get your stuff looking great in ue4 with lightmass then your problems are not the software. people are doing high end arch vis in unreal that looks almost comparable to what vray can do, except the results are realtime right away with no fussing around.

    UE4 has come a loooong ways for lighting and looking at some of the scenes on artstation there is no real reason not to use the tools built into it. super senior artists are killing it with the basic ue4 tools, so I would focus on making dope art and not so much on the tools most things can be fixed with a bit of troubleshooting at the end.


  • melviso
    Offline / Send Message
    melviso polycounter lvl 6
    @PixelMasher ; Thanks for that video link. Very eye opening. Before ur post, I did try the 32 lightmap thingy but was still getting light leaks. I will follow this video and see the possible results I can get. I am going to watch more of this guy's videos. Very helpful.
  • TorQue[MoD]
    Offline / Send Message
    TorQue[MoD] polycounter lvl 13
    ...Something I found out that is definitely worth a look is Light Propagation Volumes. Strangely, it's not on by default and you have to add r.LightPropagationVolume = 1 to an .ini file.

    I don't want to use Light Propagation volumes if it's still in "alpha" stages. Too much to go wrong I think and the documentation specifically states that it's not ready for production. Definitely going to look into the new Fortnight dynamic lighting setup.

    Thanks PixelMasher for the lighting academy video.
  • musashidan
    Offline / Send Message
    musashidan quad damage
    Mesh distance fields are a new feature used in Fortnite. Have you seen this?


  • TorQue[MoD]
    Offline / Send Message
    TorQue[MoD] polycounter lvl 13
    Mesh distance fields are a new feature used in Fortnite. Have you seen this?
    ...


     Yeah, that's exactly what I'm going to test out right now for my game. I think it will make a huge difference in my sanity plus a good performance boost over the previous dynamic lighting.
  • musashidan
    Offline / Send Message
    musashidan quad damage
    Well, best of luck. Would be great if you could post back some of your experiments/findings/results.
Sign In or Register to comment.