Error Loading Crunched Texture

I downloaded Crunch from the Unity branch of the Crunch repo. I used Crunch_x64 (which is the only binary included) to compress an ETC2AS texture (format 65, crn fileformat). Then I tried to load the texture in Unity 2019.3 but I get the following errors:

string URL = Path.Combine(Application.streamingAssetsPath, Filename);
var unityWebRequest = UnityWebRequest.Get(URL);
yield return unityWebRequest.SendWebRequest();
byte[] TexData = unityWebRequest.downloadHandler.data;
Texture2D Tex = new Texture2D(1024, 2048, TextureFormat.ETC2_RGBA8Crunched, false);
Tex.LoadRawTextureData(TexData);

I’m using the latest commit from the Unity branch, which was committed October 23rd, 2018. I checked that the binary was updated as part of that commit.

The commit notes say to use KTX (which seems wrong because ktx isn’t crunched) so I tried that and that creates a completely uncompressed file (10x the size of the crunched version) that Unity says has no texture info.

I tried DDS too and that also creates a completely uncompressed file (10x the size of the crunched version) that Unity says has no texture info.

So, I think I was right to be trying to use CRN but the crunch version error seems to be getting in the way.

Am I doing something wrong? Is Unity using a new version of Crunch which isn’t available in the GitHub repo? If so, where can I find it?

Edit: I misspelled “trying” as “crying”, which may well be a Freudian slip

1 Like

Hi,

Your approach should work for Texture2D, that is, loading a Crunch datastream by using LoadRawTextureData(). Unity however checks if the Crunch bitstream has a version set to 1 (crn_comp_params::m_userdata0). Could you validate this is the case with your bitstream?