marmotje

Hello,

I'm trying to use a spine atlas in Unity with a max size of 4096x4096. However during the reimporting of all assets which is part of our build process, the AssetUtility code keeps setting the max texture size back to 2048.

On this page https://github.com/pharan/spine-unity-docs/blob/master/spine-unity-gettingstarted.md I found a snippet mentioning this:
TEXTURE SIZES. Unity scales overly large images down by default. The Spine-Unity runtime automatically sets atlas maximum sizes to 2048x2048. If your textures are larger than this, it will cause atlas coordinates to be incorrect. Make sure the import settings are set appropriately, or decrease the maximum page width and height in your Spine Texture Packer settings.
Is this still relevant? I would like to use a texture bigger than 2048 if possible, as right now the downsizing makes it look blurry.
I don't want to move to using 2 atlases because we're using the SkeletonGrapgic (Unity UI Canvas), and some other documentation mentioned that only works well with 1 atlas. And we're using that version to make sure it works correctly with masking in the UI.

Any advice on how to proceed would be much appreciated.

Edit: I did try making a build where I changed the AssetUtility code to set max texture size to 4096. It seems to all work correctly now and it looks good. I am curious to know if there is edge case behaviour where it might still go wrong with this.

Thanks!
marmotje
  • Postovi: 9

Misaki

Sorry for the late reply, but our Unity wizard Harri is currently on vacation and will reply next week.
Avatar
Misaki

Misaki
  • Postovi: 566

Jamez0r

marmotje je napisao/la:Hello,

I'm trying to use a spine atlas in Unity with a max size of 4096x4096. However during the reimporting of all assets which is part of our build process, the AssetUtility code keeps setting the max texture size back to 2048.

On this page https://github.com/pharan/spine-unity-docs/blob/master/spine-unity-gettingstarted.md I found a snippet mentioning this:
TEXTURE SIZES. Unity scales overly large images down by default. The Spine-Unity runtime automatically sets atlas maximum sizes to 2048x2048. If your textures are larger than this, it will cause atlas coordinates to be incorrect. Make sure the import settings are set appropriately, or decrease the maximum page width and height in your Spine Texture Packer settings.
Is this still relevant? I would like to use a texture bigger than 2048 if possible, as right now the downsizing makes it look blurry.
I don't want to move to using 2 atlases because we're using the SkeletonGrapgic (Unity UI Canvas), and some other documentation mentioned that only works well with 1 atlas. And we're using that version to make sure it works correctly with masking in the UI.

Any advice on how to proceed would be much appreciated.

Edit: I did try making a build where I changed the AssetUtility code to set max texture size to 4096. It seems to all work correctly now and it looks good. I am curious to know if there is edge case behaviour where it might still go wrong with this.

Thanks!
I'm not sure about the AssetUtility / re-importing process, but we use .pngs that need to be 4096 (and sometimes even 8192) for pretty much all of our Spine characters. When we initially import them into Unity, the .pngs are set to Max Texture Size 2048 by default, so we have to increase them to the appropriate size (by just selecting the .png in the Project window and changing it in the Inspector).

I believe your Quote about incorrect coordinates is outdated. We have not had any issues.
Avatar
Jamez0r
  • Postovi: 356

Mario

Do note that texture sizes bigger than 2048x2048 may lead to issues on older or mid-range mobile devices.
Avatar
Mario

Mario
  • Postovi: 2970

marmotje

Misaki je napisao/la:Sorry for the late reply, but our Unity wizard Harri is currently on vacation and will reply next week.
No problem. It's marked for our next sprint and the main change to solve the problem is done, so it's just a matter of getting extra insight if there is any potential problem lurking.
Jamez0r je napisao/la:I'm not sure about the AssetUtility / re-importing process, but we use .pngs that need to be 4096 (and sometimes even 8192) for pretty much all of our Spine characters. When we initially import them into Unity, the .pngs are set to Max Texture Size 2048 by default, so we have to increase them to the appropriate size (by just selecting the .png in the Project window and changing it in the Inspector).

I believe your Quote about incorrect coordinates is outdated. We have not had any issues.
Thanks for sharing your experience. It gives me more confidence already that it is outdated information. On the test builds I've done so far it has been working correctly. It was just a matter of changing the AssetUtility code to set max size to 4096 so it doesn't clobber over our manually set values during out automated builds.
Mario je napisao/la:Do note that texture sizes bigger than 2048x2048 may lead to issues on older or mid-range mobile devices.
Indeed, thanks for the reminder. The vast majority of supported devices should support these larger textures, but to be sure we'll have a fallback, I am most likely going to enable mipmaps generation on the texture, and have a quality settings entry that uses half res textures, and make sure any device we detect doesn't have support for that size texture gets set to that quality before the texture is loaded in. It does increase the build size, but it will also come in handy for reducing memory footprint on low memory devices, and there's still quite a few of those around too.
marmotje
  • Postovi: 9

Harald

Sorry for the late reply. The old documentation page on pharan's github repository is outdated, please only refer to the official spine-unity page for documentation.
marmotje je napisao/la:It was just a matter of changing the AssetUtility code to set max size to 4096 so it doesn't clobber over our manually set values during out automated builds.
Please note that AssetUtility.SetDefaultTextureSettings() will only be executed when there is no texture preset assigned in the Edit - Preferences - Spine property named Atlas Texture Settings in Unity.
spine-unity Runtime Documentation: Spine Preferences
So if you have the default texture preset asset assigned at this property, you should be able to adjust resolution by adjusting the file spine-unity/Editor/ImporterPresets/PMATexturePreset according to your needs.
Avatar
Harald

Harri
  • Postovi: 3924

marmotje

Harald je napisao/la:Sorry for the late reply. The old documentation page on pharan's github repository is outdated, please only refer to the official spine-unity page for documentation.
marmotje je napisao/la:It was just a matter of changing the AssetUtility code to set max size to 4096 so it doesn't clobber over our manually set values during out automated builds.
Please note that AssetUtility.SetDefaultTextureSettings() will only be executed when there is no texture preset assigned in the Edit - Preferences - Spine property named Atlas Texture Settings in Unity.
spine-unity Runtime Documentation: Spine Preferences
So if you have the default texture preset asset assigned at this property, you should be able to adjust resolution by adjusting the file spine-unity/Editor/ImporterPresets/PMATexturePreset according to your needs.
Thank you for providing more details, it is very much appreciated.
It looks like the version we're currently using does not have the option to assign a preset.

I'll plan in to update the version we're using, but in the mean time there seems to be no issue with using the larger texture, and temporarily we've updated our local copy of the code to allow for larger max sizes.

Thanks again!
marmotje
  • Postovi: 9

Harald

Thanks for the additional info. I was briefly wondering why the fallback solution was being used (since users would rarely clear the preset), but being on an old version explains this behaviour.
Avatar
Harald

Harri
  • Postovi: 3924


Natrag na Unity