Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Basis Universal Texture Format in Unity

Discussion in 'General Graphics' started by gw1108, Jul 8, 2019.

  1. gw1108

    gw1108

    Joined:
    Jan 22, 2013
    Posts:
    4
    Fairly recently, Binomial released Basis with open source compressor and transcoder. Is it possible to use the Basis file format in Unity? Does Unity have any plans to support the Basis file format?
     
    Rich_A, j_sch and jamal-dahbur like this.
  2. jamal-dahbur

    jamal-dahbur

    Joined:
    Jul 24, 2014
    Posts:
    8
  3. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,396
    We are considering whether to support it or not.
     
  4. unity_5beiWq0X69Bkug

    unity_5beiWq0X69Bkug

    Joined:
    Jun 3, 2019
    Posts:
    6
    While Unity is considering whether or not to support the Basis format, is there any way we can implement it on our own without the engine source code? I have not found any events or functions to override that would allow us to implement it but I am curious if there is anything I have overlooked.
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,694
    To implement it yourself you'd have to compress the files into the .basis format yourself external to Unity. You could then presumably implement the transcoder as a native plugin, or manually rewrite it into c#, though I'm not sure their license allows for that. You could either load the .basis files manually like you would for manually loaded .jpg files, send the bytes through the transcoder, and then create a Texture2D of the correct format & dimensions and apply the bytes returned by the transcoder.

    You could also possibly implement them as scriptable objects so you can load the .basis files into an asset package as the raw bytes, to again transcode at runtime.

    The hard part would be having them as assets you could apply as textures in the editor. That I have no idea how you would do it.
     
  6. unity_5beiWq0X69Bkug

    unity_5beiWq0X69Bkug

    Joined:
    Jun 3, 2019
    Posts:
    6
    Good suggestions bgolus. I was thinking something along the same lines and abandoned it when I was trying to consider how to link the textures to the assets in a way that is artist friendly and integrates well with other Unity features like asset bundles. I was hoping to find some events I could tap into or functions that would allow me to implement my own functions for encoding and decoding texture assets. Assuming I could do that, it would likely work with any other Unity feature since the engine would still recognize it as a texture asset.
     
  7. theteadrinker

    theteadrinker

    Joined:
    Jan 6, 2015
    Posts:
    4
    Looks like a very interesting option for any app that loads textures from the web, however, you probably would want to pack a number of textures into a larger file to reduce number of HTTP requests.

    However it would be great if Unity would support basis in an API like: Texture2D.LoadImage(byte[] data, bool markNonReadable = false);
     
  8. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    253
    I'd really love to see the adoption of some kind of technology that minimises one or more of project size, install size, and memory usage.

    I'd imagine that since Unity is still the go-to engine for Mobile and Nintendo Switch development, the adoption of something like Basis would greatly benefit the userbase.

    https://www.khronos.org/blog/google...to-khronos-gltf-3d-transmission-open-standard

    Even moreso since Unity controls a large asset store and could support and encourage asset creators to use more optimised texture technologies.
     
  9. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,396
    Why?
    Quality-wise Basis is somewhere around that of ETC compression, so there's no real benefit from using it for mobile users.
     
  10. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,778
    Isn't the main selling point that basis supports to expand its data to various texture formats, which allows to have the same basis file that could expand to ASTC on phones with ASTC support and to ETC on phones that don't support ASTC for example. All this with the same basis file of course.
     
  11. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,694
    An ETC1 texture is 4 bits per pixel. With compression maybe 3.5 bits stored? A Basis Universal can be 0.5~2 bits per pixel. The advantage is download size.

    Granted PVRTC can be 2 bits per pixel, so there’s less advantage there.
     
  12. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    183
    >expand to ASTC on phones
    Astrologers announced a week of importing on scene load, loading time increase by +5000%.
     
  13. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,694
    Are you making fun of ASTC’s compression times? Because one of the other advantages of Basis is the compression/encoding times are much faster than ASTC, and the transcoding from Basis to ASTC is real-time. Part of idea behind Basis, like Crunch before it, is the time to load the image from “disc” and transcode it is less than loading the final format normally.

    Quality wise, the resulting ASTC won’t be as high quality as a texture directly encoded into that format, but hopefully will be better than ETC1. That is however the big question mark @aleksandrk was getting at.
     
  14. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,396
    Technically, yes. But if the quality is lower, there's no point in using ASTC in the first place, you can just use ETC2 :)
    I could see potential in using it for something to unify the format for ETC2/ETC, but not ASTC.

    This is a good point :)

    I'll bring all of this into the internal discussion. Especially since they seem to have been working on a high-quality setup for lossless transcoding to ASTC.
     
  15. Lahcene

    Lahcene

    Joined:
    Jun 18, 2013
    Posts:
    26
    Other benefits are less memory usage and faster loadi times.
     
  16. florianpenzkofer

    florianpenzkofer

    Unity Technologies

    Joined:
    Sep 2, 2014
    Posts:
    236
    Basis currently only supports ASTC with a block size of 4x4 (8 bpp). Unity uses 6x6 (3.56 bpp) by default. This means the runtime memory size using basis would increase.
     
    Lahcene likes this.
  17. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,694
    Yeah, the “less memory usage” thing is misleading. Basis means smaller on “disk” build sizes and potentially faster initial loading times. Memory usage is the same or slightly higher.
     
  18. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    253
    If you look at the typical Indie project, a significant number of gigabytes - the majority of the project - is taken up by texture files. Same for Store Assets. Reducing on-disk storage size would be highly beneficial.
     
    Lahcene likes this.
  19. florianpenzkofer

    florianpenzkofer

    Unity Technologies

    Joined:
    Sep 2, 2014
    Posts:
    236
    Are you suggesting to use basis as an alternative to e.g. PNG?
     
    Lahcene likes this.
  20. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,694
    Yeah, are we taking project folder or final built game size?

    If you really do mean project folder you're talking about source assets, and you really want to use uncompressed assets for the project, be that PNG, TGA, or PSD is irrelevant to the final built game assets. Personally I prefer TGA or PSD over PNG because it takes so long to save PNG files that now you're waiting for the PNG compress, decompress, and GPU format compress each time you update a texture instead of just the GPU compressing. PNG is bad for iteration. Basis files shouldn't be used as source assets because they're heavily compressed already, similar to a medium quality JPG (another format you don't want to use as a source format if you can help it).

    If you're talking about a built game, sure. It's basically crunch 2.0.

    Also I've never worked on a game where the textures were the largest part of either the project or build. Usually it's audio.
     
    Lahcene and florianpenzkofer like this.
unityunity