Bleed/transparent pixels when using spritesheets #9938
-
I appreciate this is a repeated topic, but I have been unable to find a solution to the what I'm specifically facing. I have a spritesheet generated with texturepacker with both border and shape padding. If I place any tiles next to each other, there always seems to be an artefact. Here is an example of what I mean: https://jsfiddle.net/uzmqadkn/ If I remove border/shape padding, I get bleed from nearby tiles. If I add more, I just get a constant 1 (or half pixel?) border around the tiles when they are placed next to each other. In the jsfiddle above, I'm increasing the scale to make it more evident as an example, but in reality, even at normal scaling, this is what I see: Aside from writing my own shader (which is another alternative I've seen recommended), is there a fix I may be missing? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Try setting a const sprites = new PIXI.Spritesheet(
new PIXI.BaseTexture(img, {
scaleMode: PIXI.SCALE_MODES.NEAREST,
}),
spritesData
); |
Beta Was this translation helpful? Give feedback.
-
We had this issue too with our tiled images that we pack into an atlas. // For tiles we want to preserve their power of 2 dimensions - so no padding!
// But we also want to prevent their colors from spilling into an adjacent tile in the atlas.
// Shrink texture coords by half pixel to avoid this.
// https://gamedev.stackexchange.com/a/49585
if (atlasID === 'tile') {
const rect = texture.frame.clone().pad(-0.5);
texture.frame = rect; // `.frame` setter will call updateUVs() automatically
} Check this post for more info: |
Beta Was this translation helpful? Give feedback.
Try setting a
scaleMode
, this tells the GPU how to interpolate pixels that are scaled (default is LINEAR).