Search Unity

Loading DXT1 files at runtime - using Graphics API OpenGLES3

Discussion in 'General Graphics' started by aracid, Jun 19, 2019.

  1. aracid

    aracid

    Joined:
    Sep 1, 2013
    Posts:
    8
    Hi Everyone

    Unity 2019.1.6f1

    I have an app that I'm moving over to OpenGLES3 and one of the components loads DXT1 files at runtime to aid in loading time into a Texture2d.

    I followed this thread - which previously worked really well!
    https://answers.unity.com/questions/555984/can-you-load-dds-textures-during-runtime.html

    With only making 2 changes to my project settings,
    Graphics API - OpenGLES3
    Color Space - Linear

    I now can't use DXT1 files, and reports this error -

    'DXT1' is not supported on this platform. Decompressing texture. Use 'SystemInfo.SupportsTextureFormat' C# API to check format support.

    Is this expected ? and is there another way to load png/jpg files into a Texture2d at speeds comparable to the dds method mentioned in that thread?

    Thanks in advance
    Brian
     
    Last edited: Jun 19, 2019
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    Hi!
    DXT1 isn't among the most popular formats being supported on OpenGL ES.
    Use ETC, ETC2 or ASTC instead.
     
  3. aracid

    aracid

    Joined:
    Sep 1, 2013
    Posts:
    8
    Hi Alek
    Thanks for your reply.

    Would the workflow be in principle similar?
    convert png/jpg -> ETC2/ASTC (offline, store somewhere on disk or on a server) then load at runtime with the speed benefits?

    Thanks in advance
    Brian
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    You can just import a texture in Unity (.jpg or .png) and select the format you need, per platform.
     
  5. aracid

    aracid

    Joined:
    Sep 1, 2013
    Posts:
    8
    Sure, that is certainly one option however my interests are for texture streaming at runtime.
    Backgrounds that are stored on a Amazon S3 bucket and I'll be updating them with out updating the app.
    Prior to this - I was streaming 4k DXT1 files and the load time's were reasonable however when I switch to jpg or png, it became super slow, which is what lead me to look into DXT1 as its mapped out and ready to display.

    Would you happen to have any suggestions around what the best solution to loading images at runtime off a server?

    This is what I'm currently using

    UnityWebRequest www = UnityWebRequestTexture.GetTexture(eachExperience.movie.image_path);
    yield return www.SendWebRequest();
    if (www.isNetworkError || www.isHttpError)
    {
    Debug.Log(www.error);
    }
    else
    {
    AddTextureToCache(Utilities.ReturnHashId(eachExperience.movie.image_path), ((DownloadHandlerTexture)www.downloadHandler).texture, eachExperience.movie.image_path, false);
    }


    Thank you again
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    Yes, the workflow will be similar in this case :)
    You just need a different tool for compression.
     
    aracid likes this.
  7. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Have you thought about using AssetBundles as your streaming textures? This should allow for streaming in the textures but they will already be in the correct format. You can still update the Assetbundles without rebuilding your app. Take a look at Addressables for an nicer way to work with AssetBundles.
     
    aracid likes this.
  8. aracid

    aracid

    Joined:
    Sep 1, 2013
    Posts:
    8
    Hi Karl

    Nope, my noob status shines at this moment.
    Thanks for pointing them out :)
    Much appreciated.
     
    karl_jones likes this.
  9. aracid

    aracid

    Joined:
    Sep 1, 2013
    Posts:
    8
    Hi there

    Thanks for the tips about all of this,

    I seem to get a warning that 'ASTC_RGB_4x4' is not supported on this platform. Decompressing texture. Use 'SystemInfo.SupportsTextureFormat' C# API to check format support.

    When debugging
    Windows SystemInfo.SupportsTextureFormat(TextureFormat.ASTC_4x4) reports False
    Android/Oculus Go reports True

    What I don't understand is that the the image still is shown on both platforms, what does the warning message actually reporting then?

    Thanks again
    Brian
     
  10. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    From the Unity documentation:
    See "all supported texture formats" section:
    https://docs.unity3d.com/Manual/class-TextureImporterOverride.html
     
    aracid likes this.
  11. ankitakumari1234

    ankitakumari1234

    Joined:
    Apr 7, 2023
    Posts:
    1
    found this issue on ios device
    texture creation failed. 'DXT1' is not supported on this platform. Use 'SystemInfo.SupportsTextureFormat' C# API to check format support.
    UnityEngine.Texture2D:.ctor(Int32, Int32, TextureFormat, Int32, Boolean, IntPtr)
    <DownloadImage>d__17:MoveNext()
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
    PlayerDetails:SetProfilePicInProfileScreen()
    LoadDataCitySelectionScreen:profielResponseGuestUser(Boolean, Response, String)
    System.Action`3:Invoke(T1, T2, T3)
    <StartRequestCoroutine>d__12`2:MoveNext()
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
     
  12. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609