TimGRS

Hello,

I'm building an avatar atlas at runtime from loose textures and everything is working except I can't seem to get the TextureFormat parameter in GetRepackedSkin() to be used. Every time the repacked atlas is created the resulting texture will be ARGB32 uncompressed. I've tried a whole bunch of different TextureFormat options from Alpha8 to ETC2 to DXT and regardless of the option, the resulting repacked texture is ARGB 32 bit uncompressed.

I see a lot of other developers on the form are using the Mix and Match system with repacked textures but couldn't find anyone mentioning using different texture compression, just mipmaps on/off and different texture sizes.

Any ideas about what could be going wrong?
// Pseudo code with some definitions omitted
Skin newSkin = skeleton.UnshareSkin(true, true, skeletonAnimation.AnimationState);
...
// Attachments found by bone index
...
Sprite newSprite = Resources.Load<Sprite>(spriteName);
AtlasRegion newRegion = newSprite.ToAtlasRegionPMAClone(Shader.Find("Spine/Skeleton"));
newAttachment.SetRegion(newRegion);
newSkin.AddAttachment(slotIndex, componentAttachmentName, newAttachment);
skeleton.SetAttachment(componentSlot, componentAttachmentName);
Resources.UnloadAsset(newSprite);
...
// Multiple loose sprites attached to the skeleton
...
GetRepackedSkin
("repacked", repackedShader, out runtimeMaterial, out runtimeAtlas, 2048, 2, TextureFormat.DXT1, false);
skeleton.SetSkin(newSkin);
skeleton.SetToSetupPose();
Screen Shot 2017-04-25 at 1.10.48 PM.png
TimGRS
Posts: 9

Pharan

Not quite sure why it's not being applied. The texture format is appropriately passed when we create the Texture2D.

I think for DXT, you need to manually call Texture2D.Compress
Since it's sort of specific to DXT, I'm not sure yet if that sort of thing should be internal to the method.

We'll put this down for review.
User avatar
Pharan

Pharan
Posts: 4427

TimGRS

Hi Pharan,

Thanks for looking into this. I did a quick sanity check and verified that the non-compressing problem is also happening in Spine's own Mix and Max example scene and MixAndMatch.cs GetRepackedSkin() call as of the March 30th 2017 version so this may be a legit bug with the repacking.
TimGRS
Posts: 9

Pharan

You may want to call texture.Compress(bool) on your end for now on the output texture.
User avatar
Pharan

Pharan
Posts: 4427

TimGRS

@Pharan - Any updates on this compression issue?
TimGRS
Posts: 9

Pharan

None. Did you try calling Compress?
User avatar
Pharan

Pharan
Posts: 4427

TimGRS

Hi Pharan,

Yes I did on Android and Compress did work in the Editor, compressing the repacked texture to DXT5. However when in iOS, Compress didn't seem to do anything in the Editor. Is there a good way to verify if the textures are compressing on Android and iOS devices? Perhaps the compression is working on device and I'm just not noticing it?
TimGRS
Posts: 9

PeterBacall

I'm having similar issues, did this get a Solution? I didn't get how to call "Compress"
Pharan wrote:You may want to call texture.Compress(bool) on your end for now on the output texture.
TextureFormat textureFormat = TextureFormat.RGBA32;

[...]

repackedSkin = repackedSkin.GetRepackedSkin ("Repacked Skin", sourceMaterial, out runtimeMaterial, out runtimeAtlas, maxAtlasSize, padding, textureFormat);

[...]
With the above code my repacked skins are ARGB
PeterBacall
Posts: 35


Return to Unity