alex_h Posted November 2, 2017 Share Posted November 2, 2017 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? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted November 2, 2017 Share Posted November 2, 2017 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. resources.myAtlas.textures['something'].baseTexture.mipmap=false; 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. alex_h and b10b 2 Quote Link to comment Share on other sites More sharing options...
alex_h Posted November 2, 2017 Author Share Posted November 2, 2017 Thanks for such a quick response, that is all very useful info! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted November 2, 2017 Share Posted November 2, 2017 Also, the more pixels the particular object covers on screen, the lesser importance of switching/batching, because fragment shader takes much more time that a switch. Batching backgrounds is really obsolete. Quote Link to comment Share on other sites More sharing options...
alex_h Posted November 2, 2017 Author Share Posted November 2, 2017 Ok cool, I will bear that in mind in the future, thanks Quote Link to comment Share on other sites More sharing options...
alex_h Posted November 2, 2017 Author Share Posted November 2, 2017 setting mipmap = false on my base textures seems to have immediately fixed the problem with an absolute minimum of hassle! Thanks again Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted November 2, 2017 Share Posted November 2, 2017 That's good. Just dont use scale<0.5 on your sprites and there won't be problems Quote Link to comment Share on other sites More sharing options...
alex_h Posted November 2, 2017 Author Share Posted November 2, 2017 point taken Quote Link to comment Share on other sites More sharing options...
alex_h Posted November 3, 2017 Author Share Posted November 3, 2017 Actually there were some other sprites in the same atlas that did need to be scaled at times to lower than 0.5. So in the end I found the best solution was to just remove the tile textures from the atlas. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.