Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

POT and NPOT textures problem

Discussion in 'Immediate Mode GUI (IMGUI)' started by Grim, Mar 2, 2009.

  1. Grim

    Grim

    Joined:
    Mar 2, 2009
    Posts:
    4
    Hello everybody,
    We need to make pretty simple thing - texture GUI for online application and we stuck with one problem.

    All objects used in GUI (buttons, panels, windows) have arbitrary size: for example, most buttons have size 30*80 px.

    If we make texture for button of exact size (30*80 px, i.e. Non Power of Two, NPOT), then button looks blurry.
    As I understand, this happens because old cards (like mine Radeon 9600) cannot work natively with NPOT textures and resize them to closest POT size and this resize ruins quality of texture.

    OK, now we make texture of closest POT size and place image of button into upper left corner of texture, like this:

    (not real texture, just sample)

    The problem now is UV-mapping this texture to 30*80 button.
    How that can be done?

    P.S. Sorry for my awkward english.
     
  2. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    using NPOT textures in the GUI works just fine. If you configure the import settings to scale the textures, they will get blurry. If you just leave them at the default value, you will be just fine using NPOT.
     
  3. Grim

    Grim

    Joined:
    Mar 2, 2009
    Posts:
    4
    And is it possible to map texture like in message above?

    Just as performance and compatibility tweak:
    As I understand, cards like R9600 _can_ render NPOT textures without software resize, but only using special extensions (in OpenGL terms), and there are even more old chipsets, which doesn't support NPOT textures at all.
    So storing GUI textures like WoW does (sample texture is taken from there) is best choice if you want your app to be maximum fast and compatible.
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    The GUI System works a bit different than regular 3d models. Even if you don't provide power of 2 it will still meet the gpu requirements as the textures are used as part of the GUI within the GUI system, not on their own.

    and no, you can't do UV transformations on GUI.xxx
    You would need to create your own gui system if texture atlas functionality is what you are looking for.
     
  5. Grim

    Grim

    Joined:
    Mar 2, 2009
    Posts:
    4
    And if UV-mapping is not possible for Unity GUI system, is it possible to hide with transparency "excess" parts of textures?

    i.e. actual panel height is 32 px, but excess 2 pixels are invisible.
    Won't there be any problems, for example with "overlapping" buttons?
     
  6. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    I won't get the terms right, so I'm not gonna use them. Create a photoshop image with a transparent background or painted alpha channel and add it to your assets. Or export it to PNG for instance if you so desire.

    This image will import just fine with its transparency for instance:

    (Ok perhaps I went just a liiittle too far in my promotion there :wink:)
     
  7. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    You should just use NPOT textures.

    If they come out blurry, then there's something wrong somewhere (and it would be good to know what you're doing that makes them blurry).

    And do not worry about hardware support; we do store textures at NPOT size (to save space), but at load time we create a texture that is next power of two, and pad that texture with dummy pixels (and if original NPOT texture is DXT compressed, we blit the DXT compressed blocks and fill the rest with dummy DXT blocks - so the resulting texture is still DXT compressed). And then we do some magic so that GUI that uses that texture is still always referencing the correct portion of that "padded up" texture.

    In other words, don't worry :)
     
  8. Grim

    Grim

    Joined:
    Mar 2, 2009
    Posts:
    4
    Wow! Thanks for such detailed answer.
    We made GUI with NPOT textures, everything is OK, no blur.
    "Don't worry" was good advice in this case :)
     
  9. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    The documentation states that compression of NPOT textures is only possible if they are exclusively used on GUITextures. Are you saying that it is also possible if they are exclusively used in GUI(Layout)? We have a project with a lot of NPOT textures being used in the GUI, and it looks like they're taking a ridiculous amount of main memory in the player—removing them frees up 800MB. All of the textures use default import settings, and are being used only in GUI calls. Are they being compressed?
     
  10. virgilcwyile

    virgilcwyile

    Joined:
    Jan 31, 2016
    Posts:
    73
    Hello, I and my team has made a tool to change the NPOT texture to POT texture. However it's just released, and it's free. It helps in reducing Memory on Android and IOS. Also disk space in your project. Check it out and share it with your fellow Unity developers. http://bluecreazione.com/imageprocessor/