Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question textures are importing with the wrong resolution?

Discussion in 'General Graphics' started by canslp, Aug 31, 2023.

  1. canslp

    canslp

    Joined:
    May 6, 2019
    Posts:
    36
    i have a bunch of 10x2 textures that i am using for color palettes, but unity says that they are actually 8x2

    here they are in the unity resource folder, definitely 10x2
    upload_2023-8-30_19-53-39.png

    and here's the texture in the editor, apparently 8x2
    upload_2023-8-30_19-54-42.png

    this is a major issue for me, because it seems to be causing the texture to be sampled just completely incorrectly. what do i do about this?
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,833
    Some of the image compression modes require an image with dimensions divisible by 4. A lot of portable devices and computers are going to find it easier to use images that have widths divisible by 4. Try turning off compression, and if that doesn't work, you could make your image 12x2 and only sample pixels in the leftmost 10x2 area.
     
    canslp likes this.
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,977
    There's also an explicit setting to change to nearest power of two you should turn off.
     
    halley and canslp like this.
  4. canslp

    canslp

    Joined:
    May 6, 2019
    Posts:
    36
    okay i figured this out, apparently by default unity will snap textures to a power of two? i just had to turn this off in the import settings. absolutely insane that that is a default setting
     
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,977
    It's not that crazy considering most of the time you want to upload the texture to the GPU, but it is something to be aware of.
     
  6. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,724
    No, this is actually the most sane thing to do.
     
  7. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,317
    It is not insane, because power of two is what all GPUs use. If you want maximum speed, that is. If you want non-POW2 textures, this is usually reserved for sprites, which are stored in pow2 atlases. So by default, if you make a texture for a videogame, it is going to be pow2. In all engines.
     
  8. canslp

    canslp

    Joined:
    May 6, 2019
    Posts:
    36
    yall i understand what 2^n texture sizes are for that doesn't make it a non ridiculous thing for a game engine to do to your art assets by default without telling you lol. sometimes images need to have ten pixels instead of eight
     
  9. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    10,977
    This is true, sometimes you do need that, but more often you need it to be a power of two, therefore the default being forcing everything to power of two makes sense.

    I think having some sort indicator that "hey, the image I generated here is resized compared to the input image you gave me" could be cool, but that's a level of polish and thoughtfulness I don't see Unity's UI being able to achieve.

    But forcing the textures to be powers of 2 by default still makes sense.
     
  10. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,724
    Why should we have to flag every other texture as a power of two if we're going to be importing those far more often?