question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Visual artifacts but no errors when using multiple spritesheets

See original GitHub issue

I’ve been struggling with this issue for a few months and would be immensely grateful for any help! I haven’t found the same problem searching past issues and forums.

For a game, I had been using one huge spritesheet (8123 x 13025), which gave me expected behavior. But then I learned older systems have maximum texture sizes (e.g., 4096 x 4096). So I tried splitting the huge spritesheet into multiple sheets (9). But using multiple spritesheets, I can’t stop getting visual artifacts. I don’t see any errors from PIXI or Chrome in the console, which has made this difficult for me to make any headway debugging.

Expected Behavior

Here’s an example of hitting crates. The “crate exploding” animation should play after.

expected

Current Behavior

Many different bugs seem to arise when I use multiple spritesheets. The kind of bug seems to vary depending on how I pack the spritesheets. All are visual artifacts. None show any errors in the console.

One kind of bug is that sprites simply seem to be missing. For example, the “crate exploding” animation doesn’t play:

missing-sprites

Another kind of bug is that the wrong texture snippets seem to be used, leading to weird artifacts rendered where sprites should be:

artifacts

Another, more subtle bug is when particles (from PIXI.particles.Emitter) seem to get replaced by flapping sheets of paper:

flapping-paper

I suspect it’s possible these are all different manifestations of the same underlying cause, like the wrong texture being sliced up and rendered.

Possible Solution

Things work fine with a single huge spritesheet, but of course older devices can’t load them at all.

My best guess is that there’s either a bug or a limit with handling multiple textures internally. I’m not sure how to tell if I’m hitting some limit, or whether I need to clean up resources differently. PIXI.settings.SPRITE_MAX_TEXTURES says 32, which seems like it ought to be plenty, but I’m not sure if I’m hitting it.

Steps to Reproduce

I have a link to the game running in the section below, but unfortunately it’s a bit hard for me to give a step-by-step since there’s a lot of code and textures 😕

Environment

I’ve tried packing sheets with both TexturePacker and pixi-packer + pixi-packer-parser. The same issue happens with both.

  • pixi.js version: 4.8.8 (but I’ve had the same problem for at least 10 months)
  • Browser & Version: Chrome 78
  • OS & Version: macOS 10.15.1
  • Running Example: It’s a bit involved, but you can open the game here, and jump a few levels in by running g.sceneManager.switchToName("007") in the console. In that level, particles become flapping sheets of paper. The animated sprite I wrote is a simple wrapper, much like PIXI.extras.AnimatedSprite, which you can look at here. The particle emitter is PIXI.particles.Emitter. (The rest of the code is there as well, but there’s a lot. I’m happy to help more if I can.)

HUGE thanks for any help. (And huge thanks already for Pixi, which has brought me great joy to work with.)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ivanpopelyshevcommented, Dec 10, 2019

I see that the source code is open, I’ll try a few experiments tomorrow.

1reaction
ivanpopelyshevcommented, Dec 10, 2019

OK, now its getting interesting! I think something wrong with bound textures cache again, we fixed it many times but it keeps happening 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual artifacts but no errors when using multiple spritesheets
So I tried splitting the huge spritesheet into multiple sheets (9). But using multiple spritesheets, I can't stop getting visual artifacts. I ...
Read more >
Artifacts around edges of sprites, only on iOS, since Unity 2021
Hi, I upgraded my project to 2021 (from 2020.3), and now my project has visual artifacts on the edges of various sprites, particularly...
Read more >
What is causing these visual artifacts on my OpenGL sprites?
My source image was fine and not being scaled for screen density. The problem was dithering after all. That one line solved my...
Read more >
Optimizing sprite sheets for Unity - CodeAndWeb
This tutorial shows you how to use optimized sprite sheets with Unity. ... standard API using the Sprite class — no additional runtime...
Read more >
Sprite Editor - Unity - Manual
documentation for information on importing and setting up Sprites. Sprite Textures with multiple elements need the Sprite Mode to be set to Multiple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found