Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Command Line Arguments To Create PVRTC Using PVRTexTool

Discussion in 'iOS and tvOS' started by inewland, Aug 11, 2015.

  1. inewland

    inewland

    Joined:
    Dec 6, 2012
    Posts:
    20
    Does anyone know the command line arguments for creating PVRTC textures?

    I've been trying to manually convert a few to have Unity load them in via 'Texture2D.LoadRawTextureData' but haven't had any luck.

    I was able to use the Xcode utility to create a Unity readable pvrtc formatted file no problem. Can't seem to get it working with the PVRTexTool.

    My current format is:
    Code (CSharp):
    1. PVRTexTool -i ~/Downloads/Tex_Natural_A.tga -o ~/Downloads/Tex_Natural_A.pvr -f PVRTC1_2,UBN,lRGB -q pvrtcfast
    Any help would be great.
     
  2. inewland

    inewland

    Joined:
    Dec 6, 2012
    Posts:
    20
    Ok so I figured it out...

    There are a few things you have to do:

    1) Encode your texture using these parameters:
    Code (CSharp):
    1. PVRTexTool -i ~/Downloads/Tex_Natural_A.tga -o ~/Downloads/Tex_Natural_A.pvr -f PVRTC1_2,UBN,lRGB -q pvrtcfast -legacypvr
    2) Next inside of Unity, you need to strip the metadata/header data from the pvr before Unity can read it.
    Note that with legacy pvr, the header size is always has a 52 bit-length.
    Code (CSharp):
    1. WWW www = new WWW("file://" + dir.ToString() + "/Tex_Natural_A.pvr");
    2. yield return www;
    3. int headerSize = 52;
    4. byte[] buffer = new byte[www.size - headerSize];
    5. System.Buffer.BlockCopy(www.bytes, headerSize, buffer, 0, www.size - headerSize);
    6. Texture2D tex = new Texture2D(512,256,TextureFormat.PVRTC_RGBA2,false,true);
    7. tex.LoadRawTextureData(buffer);
    8. tex.Apply();