Pages

Friday 17 September 2010

Thin UV charts...

Been awhile but despite appearances I have had my nose to the pixelated grindstone. I'm hoping to have a nice light volume demo ready soon so I'm looking forward to showing that off. Until then I thought I'd share the solution to a niggling problem that's been bugging me for quite some time.

The problem occured when attempting to pack a lot of very thin UV charts into a lightmap. Sections of these thin charts would often fail to render leading to black splinters on the final lightmap. Figure 1 below demonstrates this. The pillar shown is one of 12 packed into a single 512x512 lightmap.

Figure 1. Thin UV charts fail to render and cause black splinters in the resulting lightmap.


The solution is very straight forward thankfully. All that needs to be done is to check the length of every UV edge and stretch any that are too close. Initially I checked each edge length and moved UV vertices whenever they were too close together. This lead to vertices sometimes being moved more than once and often in very different directions, leading to some pretty messed up UV's. Instead,  I found it was better to determine the average of these potential new vert positions, and then move the vert to that average position. Figure 2 shows the improvement.

Figure 2. Thin charts have been expanded, no more splinters.

The lightmap remains the same size and large UV charts are unneffected. I thought I'd post in case anyone else out there was having the same problem. This might only be a problem with Microsofts UVAtlas but I seem to recall it happens with Max's built in unwrap tool as well. If anyone is interested in the script let me know and I'll make it available.

3 comments:

castano said...

Interesting, I simply use a conservative rasterizer to guarantee that any pixel that touches the geometry gets sampled. It's not very efficient, but if you are interested the code is here: http://code.google.com/p/nvidia-mesh-tools/source/browse/#svn/trunk/src/nvmesh/raster

Sander van Rossen said...

If a sliver of geometry is so thin that it only touches very few pixels, couldn't you just straighten it in texture space? The distortion would be so small that you might not notice it, and it'll make it possible to pack the texture more efficiently ..

Stefan Kamoda said...

That's a good idea. I think I only used this technique once in the end and it worked but it's certainly not the best way to go about it.

Post a Comment