UV Maps with Linear Filtering Problem

Started by
4 comments, last by LorenzoGatti 5 years, 5 months ago

Hi guys,

I'm making texture maps and running into problems because of linear filtering (D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT). It's dramatically slowing down my workflow and I still can't figure out the best way to handle it. Rectangular pieces aren't too hard to work with, I can shrink the UVs a little, but other objects are much harder to deal with. Just in case you don't know what I mean, the area outside the textured part is bleeding in because of the way the texture is sampled. How do you guys do it ? Thanks.

Advertisement

The traditional solution for bleeding problems caused by mipmapping is to add a certain amount of padding on your textures.
http://wiki.polycount.com/wiki/Edge_padding

3 hours ago, Kryzon said:

The traditional solution for bleeding problems caused by mipmapping is to add a certain amount of padding on your textures.
http://wiki.polycount.com/wiki/Edge_padding

A curiously vague  article, which talks about " suggested amounts of edge padding" instead of computing a provably sufficient amount of padding. There is a simple rule: the minimum padding is the number of pixels used in the interpolation (usually 1 for linear interpolation) at the coarsest mipmap level, in order to avoid reading "out of boundaries", and 2^n times as many pixels at the larger mipmap levels, in order to use the same UV values. Example: a 1D texture mapped to [3/8, 6/8]. The coarsest texture atlas size is 8, with 3 pixels dedicated to our texture.

0 X 1/8 X 2/8 X 3/8 A 4/8 B 5/8 C 6/8 X 7/8 X 1

Padding is needed left of A and right of C, usually duplicating the adjacent texture pixels:

X X A' A B C C' X

Note that a smaller texture (color Z) could fit in the unused space in range [0, 1/8] and its padding (with wrapping) in the rest of the range:

Z Z' A' A B C C' Z'

At the next mipmap level each texture pixel splits into two and padding pixels split into a padding pixel and an unused pixel

Z1 Z2 Z2' X X A1' A1 A2 B1 B2 C1 C2 C2' X X Z1'

Now, for example, 3/8 is in the crack between A1' and A1.

Omae Wa Mou Shindeiru

@LorenzoGatti I get your point: if you know what's the lowest level you'll ever go to, you only need to dilate the UV islands with 1 padding pixel at that level, and then higher levels can use a padding that's 2^n pixels thick, with the lowest level having n = 0.

But why is 8x8 the coarsest level in your scenario? How can you guarantee that it'll never use lower levels, like 4x4 or 2x2? In most games with a dynamic free-flying camera for example, the farthest regions of the environment are gonna display / sample from very low mip levels.

The coarsest mipmap level can be calculated relatively easily (and, why not, approximately) from object and camera geometry, I was just making up a nontrivial example with nice numbers. Note that the size that matters is not that of the texture atlas (8), which is simply the sum of several texture and padding sizes, but that of the textures (1 and 3). Mipmapping can stop at 1 pixel + padding sizes, when all values in the intended UV range interpolate to the same colour.

One could be clever by grouping sprites by size or omitting minimum size textures from even coarser texture atlas scales, freeing up padding space:

Z Z' A' A B C C' Z'

X A* B* P

The valid uv range goes from the middle of A* (no padding needed on the left) to the crack between B* and P.

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement