Search Unity

Difficulty with the use of texture atlases

Discussion in 'General Graphics' started by i_am_kisly, Mar 23, 2016.

  1. i_am_kisly

    i_am_kisly

    Joined:
    Feb 16, 2015
    Posts:
    22
    Hello! I'm having difficulty with the use of texture atlases.
    In the picture below the two copies of a model: top with texture atlas. Lower model - with the original texture.
    The inspector (right part of the window) active material with the frame of the texture atlas. As you can see, the material uses the correct tile. But this did not prevent UNITY do scan the whole atlas, not only the selected frame (tile).
    Why is the "top" model looks like? How to correct this misunderstanding? This is a bug or a feature?



    I am sorry for the machine translation from the native language.
     
    Last edited: Mar 23, 2016
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    Working as intended.

    When using the scale / offset this is not setting a tile for an atlas, it's just scaling and offsetting. If your object's UVs extant past the 0.0 to 1.0 range after you've scaled you'll still get that part of the texture.

    You can write your own shader to clamp the UVs to that tile, but it's prone to several graphical issues if you're not very careful. You're better off redoing the UVs on your object and ensuring they stay within that tile on the texture, or just within 0.0 to 1.0 and rescale as you've been doing. Be careful to leave a few pixel gap though as mip mapping and texture filtering can cause seams to show.

    If you search the forums for texture atlasing Im sure you'll find several posts on the topic.
     
  3. i_am_kisly

    i_am_kisly

    Joined:
    Feb 16, 2015
    Posts:
    22
    Ok, shader