Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
All textures within a spritelist are drawn blurry when scaled, expect for one #275
I load a list sprites from a tileset and then add them to a spritelist. When I increase the scale for these images over 1, they get drawn blurry except for one.
arcade version: 1.3.6
They should the same as this screenshot taken from the Tiled
Steps to reproduce/example code:
How I load the texture
def get_tileset_texture(self, tileset_name: str, gid: int, scale: float = 1) -> arcade.Texture: """ Fetches a texture from a tileset """ tileset = self.tilesets[tileset_name] return arcade.load_texture( file_name=os.path.join(ASSETS_PATH, tileset["image"]), x=(gid % tileset["columns"]) * (tileset["tilewidth"] + tileset["spacing"]), y=(gid // tileset["columns"]) * (tileset["tileheight"] + tileset["spacing"]), width=tileset["tilewidth"], height=tileset["tileheight"], scale=scale)
How I add them to the list
sprite = arcade.Sprite(center_x=xpos, center_y=-ypos, image_width=texture.width * scale, image_height=texture.height * scale, scale=scale) sprite.append_texture(texture) sprite.set_texture(0) sprites.append(sprite)
Hard to tell without a full working example.
I would guess it is blurry because the pixels are not landing directly on the boundaries. That is, a pixel drawn at an x, y of (0.5, 0.5) will be blurry.
It is easiest to get pixels to line up if sprites are sized in powers of 2 (16, 32, 64, 128, etc.)
Can you check this? Or post GitHub or small working example?
@pvcraven Thanks for your response, we are working together on this project here: https://gitlab.com/ByteCommander/code-jam-3/tree/assets - that branch should have the exact display as in the screenshots, though we see this blurring in all places where there are multiple sprites with the same texture. One instance of the texture is always sharp, all others blurry.
I found a workaround:
If we change the texture magnification filter from NEAREST to LINEAR in the
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
For now, we have to copy, change and monkeypatch the whole function in order to change this behaviour, which is not really cool. It would be great if you could add an optional keyword argument to
Wow, thank you. That was quick.