# How to dynamically load png for Spine 2D?

**URL:** <https://forum.defold.com/t/how-to-dynamically-load-png-for-spine-2d/76040>\
**Category:** Questions\
**Created:** [February 21, 2024, 5:16am UTC](https://forum.defold.com/t/how-to-dynamically-load-png-for-spine-2d/76040 "2024-02-21T05:16:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_R](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/max_r/32/30651_2.png) [@Max\_R](https://forum.defold.com/u/Max_R)\
**Post date:** [February 21, 2024, 5:16am UTC](https://forum.defold.com/t/how-to-dynamically-load-png-for-spine-2d/76040/1 "2024-02-21T05:16:14Z")

</div>

Hello everyone! I finally got around to the topic of project optimization and came across an interesting point that I don’t know how to solve yet.

My personal project, which I wrote about [here](https://forum.defold.com/t/flames-your-stories-to-tell/75571), is a visual novel with a lot of backgrounds animated in Spine 2D. Now they are all downloaded from the server as resources and weigh quite a lot, one episode is 50 to 70 mb, which players with slow internet complain about. 😔

To reduce the weight of the downloaded content, I wanted to upload all the art as png files and add it to the atlas dynamically. As far as I know, it is now possible to create an atlas dynamically, as well as modify an existing atlas. And all this would work fine if my backgrounds were just sprites.

For the Spine scene, it is imperative to specify an atlas with images involved in the animation. The idea of loading 1px images into the atlas and then replacing them with normal images didn’t work because you can’t change the size of the atlas at runtime.

Dynamic creation of spine models and scenes is also impossible as far as I know.

Art in png weighs 2-3 times less and would be an ideal solution, but how to add it to Spine I have no idea.

That’s why I would like to ask for help and advice from the Defold community 🙏

How can I optimize the size of the uploaded content in my case study?

Any help or advice would be greatly appreciated 🙂

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [February 21, 2024, 1:02pm UTC](https://forum.defold.com/t/how-to-dynamically-load-png-for-spine-2d/76040/2 "2024-02-21T13:02:43Z")

</div>

> [@Max\_R](#):
>
> Now they are all downloaded from the server as resources and weigh quite a lot, one episode is 50 to 70 mb, which players with slow internet complain about

This is using the Live Update feature? And with texture compression enabled?

> [@Max\_R](#):
>
> As far as I know, it is now possible to create an atlas dynamically, as well as modify an existing atlas. And all this would work fine if my backgrounds were just sprites.

Correct this is possible. But it is currently not possible to replace the atlas used by a spine model. We do have a concept of skins though but I don’t think it helps in your case either.

---

<div class="post-metadata">

**Author:** ![Max\_R](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/max_r/32/30651_2.png) [@Max\_R](https://forum.defold.com/u/Max_R)\
**Post date:** [February 21, 2024, 1:27pm UTC](https://forum.defold.com/t/how-to-dynamically-load-png-for-spine-2d/76040/3 "2024-02-21T13:27:46Z")

</div>

> [@britzl](#):
>
> This is using the Live Update feature? And with texture compression enabled?

Yes, using Live Update I download resources for a proxy that contains 10-12 Spine models. Each Spine model contains an atlas of size from 2048x2048 to 4096x4096.

Texture compression is enabled when building the project, here are my texture\_profiles:

 ![texture_profiles_screenshot](https://forum-defold-uploads.b-cdn.net/original/3X/5/6/5687e6043fb09805068cf4e03c12a775e76c6e6e.jpeg)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [February 21, 2024, 2:04pm UTC](https://forum.defold.com/t/how-to-dynamically-load-png-for-spine-2d/76040/4 "2024-02-21T14:04:47Z")

</div>

Webp is no longer supported and I’m not really sure what it is falling back to. @AGulev did a cleanup recently of values which will be available in 1.7.0:

[https://github.com/defold/defold/pull/8531](https://github.com/defold/defold/pull/8531)

I’m not sure what happens if you chose Webp. It may use a valid value or it may not compress at all. What does a build report show you (feel free to share it here)?

> **[Build reports - Bundling an application](https://defold.com/manuals/bundling/#build-reports)**
>
> While developing your application you should make a habit of testing the game on the target platforms as often as possible. You should do this to detect performance issues early on in the development process where these things are much easier to fix....

---

<div class="post-metadata">

**Author:** ![Max\_R](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/max_r/32/30651_2.png) [@Max\_R](https://forum.defold.com/u/Max_R)\
**Post date:** [February 21, 2024, 2:23pm UTC](https://forum.defold.com/t/how-to-dynamically-load-png-for-spine-2d/76040/5 "2024-02-21T14:23:35Z")

</div>

> [@britzl](#):
>
> I’m not sure what happens if you chose Webp. It may use a valid value or it may not compress at all. What does a build report show you (feel free to share it here)?

I’m using version 1.6.2 in production, but I’m going to upgrade to the latest version. What is the best compression type instead of Webp for ios/android platforms?

Here is my build report on ios:  
[build\_report.zip](https://forum.defold.com/uploads/short-url/5BYmWoXwcxiMkJuWktp6DgZfEvn.zip) (605.7 KB)

---

<div class="post-metadata">

**Author:** ![Max\_R](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/max_r/32/30651_2.png) [@Max\_R](https://forum.defold.com/u/Max_R)\
**Post date:** [February 21, 2024, 2:56pm UTC](https://forum.defold.com/t/how-to-dynamically-load-png-for-spine-2d/76040/6 "2024-02-21T14:56:10Z")

</div>

I built a project with different types of compression and here are the results:  
Webp - 428 MB  
Basis uastc - 296 MB  
Basis etc1s - 161 MB

I don’t remember why I chose webp at the beginning of the project development 😔

I read in this [forum thread](https://forum.defold.com/t/basis-etc1s-failure-on-android/71395/8) that etc1s is no longer relevant, will it also be removed or did I misunderstand?

The compression size with etc1s is impressive!
