Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Non power of 2 textures

Discussion in 'General Graphics' started by tawdry, Dec 26, 2016.

  1. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,357
    Hi
    Been going through my textires and noticed many are not power of 2 and some are power of 2 in only 1 direction. Is there a downside using these textures and what are they?Is having one side power of 2 eg (2048x1033)at least better than neither been power of 2 (1047x2033 eg).
    Thx
     
    Violet-n-red likes this.
  2. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,357
    Unity compresses the textures into power of 2 on import is this the same as if they were already power of 2 before import and do they function (benefit) same after import as if they were originally power of 2??
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,332
    Having a texture that's not a power of two on either axis will be rescaled into a power of two texture on import by default. The benefit of power of two textures is mip maps and compression. Mip maps only work properly on power of two textures, and some texture compression formats only work with power of two textures (and some only on square power of two textures).
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No.

    --Eric
     
    SamFernGamer4k and Violet-n-red like this.
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,332
    Functionally there's no difference between textures that are rescaled by Unity on import or start out as power of two initially, but the texture might not look as nice as if it was scaled by an external application or originally authored at a power of two.
     
    jmcgraw961 and SamFernGamer4k like this.
  6. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,357
    Ah good that's what i figured was just worried it might not compress so well.Guess i will try rescale the important textures myself. Thx for the input
     
    SamFernGamer4k and Violet-n-red like this.
  7. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    460
    What about 360 images that are used as a skybox in VR? If I plan to use no mip maps and my original image is of size 10000 x 5000 and I set the Texture Shape to Cube, should I enable or disable the power of two?

    Also, which compression formats support NPOT? I've read that PVRTC2 does it. In the Texture Importer I can choose PVRTC formats for compression. Are these actually PVRTC2?

    Thanks!
     
  8. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,332
    Irrelevant for cube map textures, as cubemaps must be power of two regardless of the image format. As such Unity will always produce square power of two textures for cube maps, though if you disable it Unity will not generate a cubemap and instead show an error in the console.

    The texture you're importing is used to generate 6 square face textures of the cube map (hence the name), so the original texture itself is not used for rendering. The actual resolution of the cubemap you want to use depends on the HMD you're targeting. For example, the Rift & Rift S have a roughly ~90 vertical FOV and a vertical render resolution of ~1600 or ~1770. Basically that means if your cubemap's resolution is higher than that, you're wasting resolution. 2048 x 2048 cube maps are more than enough resolution to cover all existing VR HMDs, including the Vive Pro, Index, and even the Pimax (which all have higher resolution displays & render targets, but also wider vertical FOVs than the Oculus). So honestly, using 10000 x 5000 source textures for the skybox is a bit overkill. Even half that will probably produce equally sharp 2k cubemaps.

    Ignoring the cubemap related conversation above, basically all images formats (except PVRTC) support non power of two resolutions and only need to be multiples of the format's block size. So that means multiples of 4x4 for most formats, with some added weirdness for ASTC which seems to support resolutions that don't necessarily match the block size.

    There's a lot of confusion around PVRTC 2.

    Unity does not support PVRTC 2 on any device.

    The reason for this is simple. Almost nothing supports it. The PowerVR GPUs in the iPhone 5 through to the iPhone 7 support PVRTC 2, but to the best of my knowledge Apple never chose to support the format in their implementation of OpenGL or Metal for iOS. That means even though the hardware supports it, you cannot use PVRTC 2 on any Apple device. Similarly, all of those PowerVR GPUs support many of the common desktop texture compression formats like DXT1 and DXT5, with the later even supporting the newer BC formats, but Apple similarly chose not to include support for those either. I believe PVRTC 2 is only available on some variants of the Samsung Galaxy S4 (which shipped with different GPUs depending on when / where you bought it!) and a small hand full of generic Android tablets.

    Unity's texture importer has some "PVRTC 2 bits" format options, which many people mistakenly think is for PVRTC 2. But they're for the original PVRTC in 2 bit per pixel mode (aka high compression mode), not PVRTC 2.
     
    Last edited: Sep 12, 2019
  9. alex1st1

    alex1st1

    Joined:
    Jan 26, 2019
    Posts:
    275
    2019.2 docs here https://docs.unity3d.com/Manual/ImportingTextures.html say: "You can scale up NPOT Texture Assets at import time using the Non Power of 2 option in the Advanced section of the Texture Importer."
    but I can't find that option.
    Do you see it in your Unity?
     
  10. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,626
    mekartikshah likes this.
  11. alex1st1

    alex1st1

    Joined:
    Jan 26, 2019
    Posts:
    275
    you are right - my Texture type is set to Sprite. If I change it to Default - I will get Non Power of 2 in Advanced subfolder.
    BUT MY SPRITE RENDERERS WILL NOT RENDER THAT TEXTURE!
    What type of texture type shoul I use for 2d game?
     
  12. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,626
    For sprites, set the image type back to sprite and pack them into one or more texture atlas:
    https://docs.unity3d.com/Manual/class-SpriteAtlas.html
    Since the size of the atlas will be a power-of-two that will cover everything.
     
    mekartikshah likes this.