Home Technical Talk

Texture compression

snake85027
polycounter lvl 18
Offline / Send Message
snake85027 polycounter lvl 18
I have a texture compression question. I am using Unity and right now I am using png for my texture format. I went through and used save for web png24 format to lower the file size. Not sure if this is the best way.

When I did a build and looked through the txt files it says my file size was much larger than what it shows in the folder. When I saved it using " save for web" I thought it saves it as its new files size and not as a compression. How do I save a texture as its true file size?

I heard that unity will uncompress the textures anyway during the build so whats the point of compressing textures?

Replies

  • jRocket
    Options
    Offline / Send Message
    jRocket polycounter lvl 18
    Video cards and other graphics devices can only use certain kinds of compressed formats and each platform(standalone, web, android, ios, ect) will each have their own unique compression formats that work with their specific hardware. Keep in mind that this is completely different from your png compression, which is just locally compressed and not what builds would include. Also, these compressed formats usually have some limitations, not just to color accuracy and lossyness, but also in having the dimensions be powers of two.

    Therefore, you should always give Unity your uncompressed files and let it do the compression for you. You can choose which kind of compression to use for each platform in the import settings in the Inspector for each texture. If you don't want any compression due to lossyness or a non-power-of-two texture, you can set the format to Truecolor.
  • snake85027
    Options
    Offline / Send Message
    snake85027 polycounter lvl 18
    When unity does the compression. When you build it out will it then uncompress it?
  • GlowingPotato
    Options
    Offline / Send Message
    GlowingPotato polycounter lvl 10
    Search for DDS compression, DXT1, DXT5 and DXT5NM or BC5
  • rollin
    Options
    Offline / Send Message
    rollin polycounter
    snake85027 wrote: »
    When unity does the compression. When you build it out will it then uncompress it?

    As you've already mentioned it wouldn't make any sense, would it?

    So forget this. Unity compresses into various types (depending on build target) of video card compatible formats.

    Depending on what you put in this file can be bigger then your source file.

    This might sound confusing but "texture compression" in unity should be more referred to as "texture conversion". That way it makes more sense
  • Farfarer
    Options
    Offline / Send Message
    Yeah, generally you'll want to feed in high bit depth source textures, you won't see any advantage to compressing them before sending them into Unity, as Unity converts them to platform specific texture formats anyway.

    You've got some options with Unity for it's texture compression, which are on the texture itself, as well as some per-platform options.

    It is possible to load some simple formats into Unity at run time (JPG and PNG). But even then it's going to convert it in memory to its own format that's compatible with the graphics card.

    If you're looking for smaller texture size, try the crunched compression option that Unity has (although the image quality will suffer).
  • Eric Chadwick
  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    Also note that crunched texture compression only affects the image size for downloads, disk space, and main memory, not video memory where it's still just DXT compressed and will have the same footprint as a regular old DXT compressed texture.
  • snake85027
    Options
    Offline / Send Message
    snake85027 polycounter lvl 18
    I have a question on my psd file. Down at the bottom it says Doc: 6.00m/82.9m. Why is there to file sizes there?

    Usually my work flow is creating a psd file then doing as save as PNG , then drag the png into unity. Is this a proper way?

    Also what do you guys use for unity?

    and for making the texture file size down, you guys do that within the texture itself within unity?

    thanks again. I just never really had to do this. I usually just created a texture and if the model is small then I would use a small texture size.
  • Eric Chadwick
    Options
    Offline / Send Message
    That's a Photoshop thing. The help file says:
    Document Sizes
    Displays information on the amount of data in the image. The number on the left represents the printing size of the image—approximately the size of the saved, flattened file in Adobe Photoshop format. The number on the right indicates the file’s approximate size including layers and channels.

    I use my PSDs directly in Unity, works great.

    The only time I avoid using PSDs directly is when the PSD is really large, and we're using source control to share files among our team (SVN, Perforce, etc.). In that case the programmers don't want the slowdown from having to grab my latest giant PSD files, so I save a TGA format for Unity instead.

    But really, if the PSD is gigantic, then usually that means I'm doing something wrong. Like using a huge number of unnecessary layers.

    Another reason to use an intermediary though is if I'm using a higher bit depth, 16 or 32 for example instead of the standard 8 (24 bit color is 8 bits per channel), but the engine doesn't support the higher depth. Then I preconvert down to what it needs. But I think Unity supports 16bit? Haven't used 16bit in a while.
  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    Unity supports 16 bit natively and it can also automatically convert to 8-bit for compression although it doesn't dither down from 16 bits like Photoshop does.
  • Xenobond
    Options
    Offline / Send Message
    Xenobond polycounter lvl 18
    I keep my psd's in the same directory and with the same name as my output tga or png. I add a . to the front of the file name and Unity won't see it. That way when you'd normally only check in the flattened file. You can add a . to directories for the same effect, but that's not something that Windows likes to see.
  • Farfarer
    Options
    Offline / Send Message
    Yeah, I keep my PSD and source assets in an AssetsSource beside the Assets directory and save everything out to 16bit PNG for Unity.

    Didn't know about the dot trick, I'll keep that in mind in future :)
Sign In or Register to comment.