x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Couple of questions regarding Lightmap UV alignment

Hi, two questions about lightmaps and texel density:

a) does this mean that the edges in the UV channel are not pixel aligned? alt text

b) If I have non rectangular walls (eg a pentagonal wall on one side of a room) what is the best approach to have all the edges pixel aligned in the lighmaps' UV channel in order to prevent jagged edges?

Product Version: Not Selected
Tags:
more ▼

asked Sep 03 '14 at 11:54 PM in Rendering

avatar image

devel.bmad
439 43 49 65

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

First off, with Texel Density you want to make sure that you're assets are close to the same resolution. They don't have to line up exactly but you want to make sure that they are close the same size (indicated by the difference in color).

For example, if you're setting up several modular walls, you would want to make sure that when you make the lightmap that wall one uv is relative to wall 2. There are times when I've been making modular walls in Max I'll use a unwrap modifier on several assets at once to get my lightmap texel sizes to be identical.

For your second questions, there are a couple of things you need to consider first and this may determine how you decide to model the pentagonal wall.

1) If you can break this up modularly this will give you the most UV space to work with without having to scale all the faces down extraordinarily to fit the 0,1 space. This will also allow you to not have to bump the lightmap resolution up significantly in UE4 to get better static shadows.

2) If you're going to build the entire pentagonal wall as one asset and have additional walls that are modular you'll need to scale those down to be roughly the same size as your lightmap UVs for the pentagonal wall.

There is a ton of reference information on World of Level Designs website regarding lightmapping that may help you further.

Also we have our documentation for using lightmaps and lightmap density that may help as well.

If you have any further questions about lightmaps or something is unclear feel free to ask. Lightmapping can be daunting and it does take a bit to get a full grasp on how they work and can make your assets look great! :)

Tim

more ▼

answered Sep 04 '14 at 06:36 PM

avatar image

Tim Hobson ♦♦ STAFF
48.8k 888 103 879

avatar image devel.bmad Sep 05 '14 at 02:26 PM

Thank you for answer Tim, I've already checked these docs but I will go through them again because learning lightmapping is definitely an iterative process and every time I understand something more ;)

Just a couple of things about your answer:

They don't have to line up exactly but you want to make sure that they are close the same size

Ok, but are those squares indicative of the real texel of the lightmaps textures? I mean: ok, the densities on the two walls above should be the same color, no matter the alignment of the squares. But does the picture above mean that on both walls there are texel not aligned with the edge of the faces? Many artifacts I get seem to be linked to UVs not pixel aligned (so the dark outside the wall leaks in, for example) In this specific case, I'm pretty sure UVs should be correctly aligned. Is it 1 square = 1 Texel?

1) If you can break this up modularly this will give you the most UV space to work with without having to scale all the faces down extraordinarily to fit the 0,1 space.

Ok, but my problem in this case was: If I have a mesh with just 1 pentagon plane, should all the vertex of the pentagon put on a square (so, for example, all the 3 upper vertex end up in the same top line) so that all the edges are perpendicular to avoid jagged shadows at the contact with other walls? This approach gives me good edges, but quite skewed texels. Is there a better solution? Sounds a bit confusing, does this make sense to you?

Thanks for your help!!

avatar image Tim Hobson ♦♦ STAFF Sep 05 '14 at 06:37 PM

Some of this could be better answered with pictures I suppose, but I'll do my best to answer.

Yes, the density of the squares should be the same. With regards to lightmap the texels do not have have to be aligned. The best practice is for any hard edges to have those faces independent of each other with a padding between them for shadow baking and to prevent any shadow/light bleed being baked.

With the wall leaks, this could be a couple of things. Make sure your UV Islands are spaced far enough apart. Make sure there is a padding between the edge of the lightmap UV and the UV island. With regards to the Mesh, There will be some light leaking but this can be fixed by making sure the meshes have no spaces between them and possibly overlap just a little. This will close off the models to block light leak from happening.

The lightmap UV islands do not have to align faces to each other. Light information is being baked once lighting is build. If the face is rotated in the UV space it will not affect how the lighting information is baked. It's the same with a diffuse texture. You can rotate the UV island any direction but so long as the model is facing correctly it will show the texture correctly.

I've put together a simple scene with 3 different lightmap boxes to hopefully help explain. This would probably be better done with more complex geometry but hopefully this will help as well.

The lightmap boxes: 1) This box has all the faces attached. You can see on the corners you get soft shadowing because the bleed from the shadows blend rather than making it look like a hard edge. 2) This is a (almost, I didn't align the edges to a grid point as shown in WoLD's pages just because of time constraints) properly lightmapped cube with padding between each UV island 3) This last one has a lightmap that has faces that are different scales. You should be able to see that some of the faces get sharper shadowing resolution that others.

Continued next post...

avatar image Tim Hobson ♦♦ STAFF Sep 05 '14 at 06:40 PM

Continued...

The 4th cube is the same scaled cube with more shadow information being baked on to its surface to help illustrate this shadow resolution a little bit better.

Lightmapping is a bit of an art in itself so it can take a while to get used to and get it right.

If I've been confusing or need to explain something better please let me know.

Also feel free to post more pictures of your lightmaps or post assets and I'll take a look and see if I can help further.

Here is a link to the setup I mentioned above.

Tim

avatar image devel.bmad Sep 05 '14 at 09:35 PM

Thanks Tim, very exhaustive and useful as usual, and your examples are very clear. My point was kind of different, though:

Pixel alignment: I'm referring specifically to the issue described at the point:13. ON GRID in http://worldofleveldesign.com/categories/udk/udk-lightmaps-01-basics-and-important-principles-for-creating-using-lightmaps.php

In my image above is there an issue of this kind? is it possible to use lightmap density mode to spot edges of the UV that fall in-between pixel space of UV layout? [If I understood correctly your response, the answer is no, right?]

Shapes with oblique edges: My question was specifically addressing shapes that need to have oblique edges. Whenever there are rectangles I have no issues, but if my shape need to have oblique edges I tend to have this sort of artifacts:

alt text

..unless I artificially map the shape to a different shape with only perpendicular edges (which has the side effect to create skewed texels in the lightmaps). For example, how would you layout the lightmaps UV for this shape? https://drive.google.com/file/d/0B7SpUfi4PH7aN0RNaVhJZDk3N2c

In the 2 UV channel there is a "rectangulized" layout with only perpendicular edges. Is this the best solution? (please ignore the empty space around this island, I've removed other pieces of the same mesh in order to have a clearer example)

avatar image Tim Hobson ♦♦ STAFF Sep 05 '14 at 10:42 PM

With the On Grid you want to make sure that you setup the Grid in your modeling software. It's best to know your target lightmap resolution. This is the on grid point you want to make sure you mesh follows.

ie. If you are targeting a lightmap resolution of 128 you would use the following formula to get your grid spacing for the UV. (Step 2)

Take the number of pixels you want divided by 1 to get the grid spacing.

1 / 128 = .0078125 for grid spacing.

This is important because any vertex that falls between the grid point will be shadowed causing the jaggies that you mentioned.

Here are the redone lightmap images using the settings above. In this first image is the lightmap density changed no be stretched vs the original. The important thing to remember here is that you want the vertices to fall on a grid point but that doesn't mean they have to be straight lines as this will stretch your shadows as indicated in the second photo. You can see in the original on the left that the shadows are stretched vs the less jaggy edged ones on the right.

Image 1: alt text

Image 2: alt text

I hope this helps. I know this is a lot of information and if anything seems unclear or confusing let me know and I'll gladly help! :)

Tim

Here's a link to the redone lightmap for your mesh to give you an idea.

lightmap1.png (201.9 kB)
lightmap2.png (203.1 kB)
avatar image devel.bmad Sep 06 '14 at 12:08 AM

The important thing to remember here is that you want the vertices to fall on a grid point but that doesn't mean they have to be straight lines as this will stretch your shadows as indicated in the second photo

Thank you Tim, I will look into that! Very helpful as usual. I was under the impression that any not-straight line could cause the jaggies at the intersections of two faces, I'll try your approach and see if it works for me. Thanks again in the meantime!

avatar image devel.bmad Sep 06 '14 at 09:36 PM

The important thing to remember here is that you want the vertices to fall on a grid point but that doesn't mean they have to be straight lines

Digging further in the subject, especially in the issues linked to straight lines / not straight lines. This sounds easy for simple flat objects, but doesn't apply in my projects whenever I have to do the layout for complex / irregular / high poly objects.

For example, how would you layout this object: https://drive.google.com/file/d/0B7SpUfi4PH7aVjF3YUdVczFrWTg ?

In the 2 UV channel you can find my current solution, which is pretty suboptimal, since it requires very high densities in order to avoid artifacts close to the seams.

(btw I'm using blender for modelling and UV unwrapping the objects)

avatar image Tim Hobson ♦♦ STAFF Sep 08 '14 at 04:22 PM

For things that are more like organic objects or flowing objects you don't necessarily have to have points on the grid. Anything with a straight edge is best to have on a grid line. Something like the object (looks like a couch cushion but I could be wrong) can be pelt mapped and placed. I wouldn't worry about the edges as much with organic/rounded object.

I do want to point out that this object is a little high poly though. Even made my computer chug when trying to pelt and move nearly 13k polys for a single side.

The key with organic objects would be placing the seam in the right place rather than focusing on the verts being on a grid point. As you saw in the WoLD examples their work is mostly showing setting up hard surface styled edges.

Here is the FBX I re-did the 2nd UV for. I looked at it in UE4 with resolutions of 64,128,256,512 with a pole that casts shadows and couldn't see anything that was artifacts aside from resolution. There is some jaggies on the pole shadow cast but this is expected.

avatar image devel.bmad Sep 08 '14 at 04:42 PM

Hi Tim, I'm afraid you forgot the link, I would really be interested in how you did unwrap the 2nd UV because I didn't find a good solution at the moment. I know, this object is definitely too high poly, but the same problem (points on the grid) applies also to much simpler objects and this was a good example.

This is the kind of artifacts I'm getting with my US and that I was trying to solve aligning the points. Please note that the resolution I'm using is already 512 (though the scene relies on a lot of indirect lighting, which is very boosted here. probably with more light this would be less visible)

alt text

avatar image Tim Hobson ♦♦ STAFF Sep 08 '14 at 05:08 PM

https://www.dropbox.com/s/kq2nep4ajwzioom/CouchCushion.FBX?dl=0

Here's the link. Got a little carried away right before heading out to lunch and forgot it! Oops! :)

I really didn't do anything special with the lightmap here and there are still some minor issues with it around the edges of the UV islands, but this is mostly due to the amount of polys for the object and my pelt then relax method to get something for the 0,1 space.

avatar image devel.bmad Sep 09 '14 at 05:07 PM
avatar image Tim Hobson ♦♦ STAFF Sep 09 '14 at 08:29 PM

Here is a test project that will go through some of the following. > open map LM_Test

Here are my findings base don that link.

My setup: Built two wall meshes with a target lightmap resolution of 128

Mesh 1 - LM grid .0078125 for original settings (1/128 = grid spacing) Mesh 2 - LM grid 0.00793650 for new method (1/126 = grid spacing)

The answer is yes and no. There are factors that it can apply and where it will give you the same results as the current method of (1[lightmap resolution] = grid spacing)

The new method will give you better results pending that you set at the bare minimum set the environment color closer to the White spectrum rather than black in World Settings. You will still need to adjust Indirect Lighting Smoothness to something like .6 and the Indirect Lighting Quality to 2 to get good results.

Here are the results when not adjusting the anything in World Settings: alt text

Here is the result when only changing Indirect Lighting Smoothness and Indirect Lighting Quality.

alt text

While this helps a little you can see that there is no significant change.

However...Check the next post for the results!

lm_new1.jpg (68.8 kB)
lm1.2_new.jpg (80.0 kB)
avatar image Tim Hobson ♦♦ STAFF Sep 09 '14 at 08:34 PM

Here are the final results! ...

alt text

It may be hard to notice here but there is a noticeable difference with the alternate method. It's much more noticeable in the project I uploaded above.

Give it a shot and let me know what you think.

Tim

lm2_new.jpg (93.9 kB)
avatar image devel.bmad Sep 09 '14 at 11:22 PM

Hi Tim, thank you for your tests, they show pretty interesting results, but I'm not sure this is the ideal setup to see the issues caused by this kind of pixel misalignment because the lighting of the nearby meshes is quite similar.

I've done a few test in one of my projects, and this is what I've found:

In this corner (top mesh) you see the typical artifacts generated by misaligned UVs (texel half lit and half dark)[AO visualisation is disabled from lighting components]. The mesh has a density of 128, and I'm sure I had correctly aligned all the points to a grid of 128 (I'm using blender, I've loaded a bitmap of 64pixel and snapped).

alt text

If you check the density, texels on the top mesh do not appear aligned (exactly the issue I was asking you about at the beginning of the thread):

alt text

[to be continued..]

avatar image devel.bmad Sep 09 '14 at 11:32 PM

..I've re-done the UVs using a 126 grid as in the alternate method. This is the density I get: alt text

..which is exactly what I would have expected!! [please ignore for the moment the other issues, like different densities and skewed texels, I'm just talking about the texels alignment - none of the yellow one is clipped here]

And the results, indeed, are noticeably better:

alt text

All the settings are the same. Just changed how UVs are snapped. In short, I think this guy is right, afterall.

Now: this would explain many issues I was not able to understand before. But it is also a huge issue (well.. kind of): because this mean that if I want to change the density for this mesh I have to rework all the UVs if I want to keep a perfect alignment!!!

Try changing the density in your sample project to 64 or 256, and check the alignment of the texels in the mesh with the alternate method.... If you align to 126, doubling the density messes all up, because now you should snap to 254 (!=126*2) What do you think about it?

avatar image Tim Hobson ♦♦ STAFF Sep 10 '14 at 02:57 PM

Now: this would explain many issues I was not able to understand before. But it is also a huge issue (well.. kind of): because this mean that if I want to change the density for this mesh I have to rework all the UVs if I want to keep a perfect alignment!!!

This has always been the case. You select a target resolution for your LM and you build snap your vertices to the grid accordingly. (snapping ofcourse more recommended for hard edged objects.

Try changing the density in your sample project to 64 or 256, and check the alignment of the texels in the mesh with the alternate method.... If you align to 126, doubling the density messes all up, because now you should snap to 254 (!=126*2) What do you think about it?

To go back to the previous statement. Changing the LM resolution from anything other than the targeted one will give you lower results. The point of having the grid snap for each LM resolution is to make sure the LM is baking properly.

Even though using the method you posted from the UE4 Dev Reddit is a grid set to 126 vs 128 you would still set the LM resolution in UE4 to 128.

avatar image devel.bmad Sep 10 '14 at 06:47 PM

Ok, I was snapping everything to 1/64 and thought that being 128, 256 and 512 multiples, my vertex would stay also snapped (to multiples of 2, 4 and 8 pixel respectively).

This is no more true if I'm snapping to a 1/62, 1/126 and so on. I didn't found explicit references to this in the documentation, but maybe I've not looked in the right place. It could be probably useful to talk about the two pixel of border a little more exlicitely, I've found the technique quite useful. Snapping again the UVs in any case is not such a problem, and could be done in blender quite easily once I know it need to be reapplied. Thanks anyway again for your response and your help!

avatar image devel.bmad Oct 11 '14 at 11:03 PM

Hi, do you think this approach is achievable also with the auto UV introduced in 4.5? In order to achieve a 128 lightmap, I've tried to set "Min Lightmap Resolution" and/or "Light Map Resolution" to 126 but I didn't manage to achieve the same results. Any suggestions?

avatar image Tim Hobson ♦♦ STAFF Oct 12 '14 at 03:57 PM

If you want the most control over your LMs you'll want to make them manually. Otherwise you can test and see what the results are with the auto-UV feature. I've not really used it that much in my personal projects thus far because I've already had custom LMs made. The next project I'll test it more. But, again, if you want the most control you'll need to make them yourself.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question