Download

How to reduce lightmapping artifacts

Hi all,

I’m looking for ideas how to reduce artifacts of static lighting in the attached image. There are three main types of artifacts:

  1. Bleed (red arrow): That seems to be caused by the very narrow edges of the panels which are often significantly darker than surrounding flat parts. The edges are already unwrapped with a lot of strech to reduce this artifacts.
  2. Aliasing (green arrow): In some sense a special case of the first. It can be eliminated by aligning all edges with the u or v-axis. However this sounds not like the best of all ideas as it introduces significant stretch.
  3. Inconsistent Lighting (blue arrows): The geometry is identical on the left and right part but the two islands receive very different lighting. This seems to be caused by too imprecise sampling in combination with bleed. (the edge between the two blue arrows is not the problem, this can be fixed easily. The problem is that the the same geomerty sometimes becomes very bright and sometimes extremely dark with almost identical lighting conditions)

The simplest and obvious solution is to increase the lightmap resolution, which however sounds not like the best idea as this application is targeting mobile devices.

I’m looking for more elaborate ideas how to optimize the geometry and/or uv layout to get better static lighting.

(Please don’t suggest using material techniques like normal mapping instead of geometry here, that doesn’t look as good as real geometry on mobile in this case.)

Thanks!

You’re correct, to improve static lighting on meshes, you’ll need to make sure you have optimal settings.

Since you’re targeting mobile, you can’t up res your lightmaps since that would eat away at your devices limited memory.

Creating optimal lightmap UVs is one of those things that requires a lot of experience and technical knowledge to get “right”- I come across colleagues in the AAA games industry all the time that still don’t know how to make the best lightmap UVs, so don’t feel bad if this is taking more time than it should to figure out.

There’s no way I can explain all the techniques I use to create optimal UVs for games, but here’s some important points to consider:

  • keep UV shells as continuous as possible; the more seams, the more artifacts
  • unlike texture UVs, lightmap UVs can be stretched and pulled- if creating a continuous UV shell means it has to be stretched to fit in 0-1 space, that’s fine. It’s preferable to have a continuous stretched shell, than several fragmented shells that have no stretching
  • always keep UVs in 0-1 space
  • never overlap UVs
  • create seams in naturally occurring areas; for example place seams in hard edges areas like in the corner of a table mesh, not across the top flat surface of a table
  • for most objects, artists can do a UV planar projection and then just relax the UVs so there’s no overlaps- this will usually yield the best lightmaps **and **it’s the fastest kind of UV mapping technique there is

Here’s a link from Epic explaining most of the same techniques I use; if you go through it and adopt these best practices for yourself, you should never have another lightmap issue again for the rest of your career:
https://docs.unrealengine.com/latest/INT/Engine/Content/Types/StaticMeshes/LightmapUnwrapping/

Does stretching affect the accuracy of a lightmap?

Yes, but in a fuzzy way. It’s bad to have very different texel density within the same object light map. It’s OK to have somewhat stretched/warped/anisotropic texels in a light map, as long as the overall density is consistent, and you don’t stretch more than, say, 2:1 or so.

Another thing that’s important: gutters! Leave several pixels of margin between separate UV patches. For a 1024 texture, a 16 pixel gutter is not too much. For a 128 or smaller texture, you still want 4 or more pixels of margin.

Thanks for the advice.

However I just stumbled uppon what might be the source of many of the artifacty I’m getting. Could it be that the static lighting in UE4 doesn’t like hard edges, i.e., touching faces which don’t share vertices?

485aa18dd761307f8332b2dee06b2008fff28e1b.jpeg

The edge marked with the blue arrow is clearly darker than both of the faces touching. What I would expect as artifacts at first, is bleed from one of the faces onto the other, but not a dark stripe along the edge. (No optical illusions involved. I checked the color values, there actually is a dark stripe.)

You should not get dark anything ( shadows yes if that applies) unless maybe ( I"m not lightmapping pro at all, I suffer with issues myself atm) there are duplicate edges/faces somewhere or not enough space between islands ?

DUnno just throwing that out in case it sticks :wink: