Growler

Texture cache overflow: 16 texture units available.

Recommended Posts

Using MelonJS 5.1 (I cannot upgrade at this point), I'm creating a fairly large adventure game. My TMX map loaded fine until I added water tile layer:

https://i.imgur.com/i5kpTuc.png

https://i.imgur.com/BzsxXTn.png

At which point I started getting error: Texture cache overflow: 16 texture units available.

Error name is me.video.Error

Digging into the code, I see there is a max size for the Texture Cache:

        validate : function () {
            if (this.length >= this.max_size) {
                // TODO: Merge textures instead of throwing an exception
                throw new me.video.Error(
                    "Texture cache overflow: " + this.max_size +
                    " texture units available."
                );
            }
        },

How can I fix this?

Btw this seems to have been fixed in 2015: https://github.com/melonjs/melonJS/issues/595

@obiot @Parasyte

Share this post


Link to post
Share on other sites

the issue is that WebGL has a limited amount of texture, and as of today the limit is 16 for ~70% of devices :

https://webglstats.com/webgl/parameter/MAX_TEXTURE_IMAGE_UNITS

in my opinion the only way to fix that is either to pack/merge your tilesets directly, or to use TexturePacker (that was the fix back in 2015) when possible (https://github.com/melonjs/melonJS/wiki/How-to-use-Texture-Atlas-with-TexturePacker)

 

 

Share this post


Link to post
Share on other sites

@obiot This bug is happening again, but only on Mandarin version, even though I'm loading I think fewer overall assets than the working Spanish version.

Question: what are texture units (i.e., what does "16 texture units" mean?) and how do I compare it to overall loaded texture size?

If I print out game.map_texture, how do I compare it to see if it's below 16 units?

        game.map_texture = new me.video.renderer.Texture(
            me.loader.getJSON(`${country}_map_items`),
            me.loader.getImage(`${country}_map_items`)
        );

Mandarin Version: Printing out length for my three texture atlases: 

console.log('Game Texture: ', Object.keys(game.texture.atlas).length, game.texture);

> length of game.texture.atlas is 1236

console.log('Game Map Texture: ', Object.keys(game.map_texture.atlas).length, game.map_texture);

> length of game.map_texture.atlas is 354

console.log('Game Player Texture: ', Object.keys(game.player_texture.atlas).length, game.player_texture);

> length of game.player_texture.atlas is 107

Working Spanish Version: Printing out length for my three texture atlases: 

> length of game.texture.atlas is 1215

> length of game.map_texture.atlas is 358

> length of game.player_texture.atlas is 107

---

Mind checking the game out?

Spanish: https://spywatchlex.com/spanish/login.html

Mandarin: https://spywatchlex.com/mandarin/login.html

Use promo code "LEEROY" for free full game access. You're able to see the asset list loaded.

Images of my packed assets on disk:

Spanish: 

https://imgur.com/gWqzXJs - map items

https://imgur.com/m7Ol433 - texture

Mandarin:

https://imgur.com/lR0vSeB - map items

https://imgur.com/j10okXE - texture

 

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.