Jump to content

Tiling Sprite artefacts


Recommended Posts

I am using a TilingSprite for the background of a game. Its a top-down view so I'm setting the tiling sprite tilePosition x & y as the player moves around. I'm using a 256px square tile that is in a texture atlas I have generated in texturepacker, and I have set the sprite extrude value to 2 within texturepacker. But I'm still seeing lines appear between the tiles intermittently as I move around in the game. Is there something I'm missing? Would I maybe be better off using an individual image as texture source for the tiling sprite, rather than an atlas subtexture? I have added my tilingsprite source images to my atlas with the intention of minimising the number of calls to upload textures to the GPU, but perhaps a tiling sprite texture should be an exception to this guideline?

Link to comment
Share on other sites

1. Check that pixi doesnt enable mipmapping for your atlas. Make sure to disable it just after loading, you have to find a common baseTexture, so you can use any element of "textures" to access it.


2. You can also fiddle with `tilingSprite.uvTransform` (to be renamed in v5), the value you are looking for is clampMargin: https://github.com/pixijs/pixi.js/blob/dev/src/core/textures/TextureMatrix.js#L46 

Try change it to -0.5.


Adding TilingSprite images in atlas is ok, but there are no performance gains at all: TilingSprite uses different shader and switching shader costs more than switching a texture. Also it doesnt use batching.

I've added support of atlases to TilingSprite and Mesh, and made TextureMatrix class only because people like to put everything in atlas, it really looks cool, and pixi team really wants our users to be in comfort. Other WebGL libs don't allow that and just force user to use separate textures for such things.

However, if you need mipmapping for atlas elements, you really have to move TilingSprite out of it, because there's no way it'll work. Btw, in case of mipmaps on atlas, padding must be power-of-two more than scale that you use on elements.

Link to comment
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.

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.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...