Noeski

Hello,

I am using the latest version of Spine with Unity 2019.3 and there seems to be a bug when applying PMA while cloning sprite attachments.

This is due to the way Spine implements CopyTexture using Graphics.CopyTexture if it is supported which may or may not finish before calling Texture2D.Apply which is used to apply PMA - according to the Unity docs:

"Calling Texture2D.Apply, Texture2DArray.Apply or Texture3D.Apply after CopyTexture yields undefined results as CopyTexture operates on GPU-side data exclusively, whereas Apply transfers data from CPU to GPU-side."

I would recommend adding a flag to CopyTexture in AtlasUtilities so that the PMA can be applied directly during the copy and if the flag is not set go ahead and use the optimized Graphics.CopyTexture.
You do not have the required permissions to view the files attached to this post.
Noeski
  • Posts: 11

Harald

Thanks for reporting.

Could you please describe where you found the respective pair of calls to Graphics.CopyTexture() and Texture2D.Apply() that you mentioned above?
Do you mean this line of ApplyPMA()? Or this call to Graphics.CopyTexture()?
User avatar
Harald

Harri
  • Posts: 1524

Noeski

Inside
public static AtlasRegion ToAtlasRegionPMAClone (this Sprite s, Shader shader, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps, Material materialPropertySource = null)
var tex = s.ToTexture(textureFormat, mipmaps);
tex.ApplyPMA(true);
and
public static AtlasRegion ToAtlasRegionPMAClone (this Texture2D t, Shader shader, TextureFormat textureFormat = SpineTextureFormat, bool mipmaps = UseMipMaps, Material materialPropertySource = null)

var newTexture = t.GetClone(textureFormat, mipmaps);
newTexture.ApplyPMA(true);
Noeski
  • Posts: 11

Harald

Ah, thanks very much, I overlooked these two, very good catch!

I opened an issue ticket here:
https://github.com/EsotericSoftware/spine-runtimes/issues/1616

Thanks very much for digging in so deep and finding the cause, very much appreciated of course!
User avatar
Harald

Harri
  • Posts: 1524

Noeski

No problem! Thanks for all the great work!
Noeski
  • Posts: 11

Harald

This issue has just been fixed, new unitypackages can be downloaded here as usual:
Spine Unity Download

Thanks again for the great bugreport!
User avatar
Harald

Harri
  • Posts: 1524


Return to Unity