Hi All,
I have a problem with a tile. You can see it:
Artifacts are visible only in rare positions of the camera. This is particularly evident when you move. I tried to set different filters, it does not work. To work with the camera I use a package HUMP. To draw tiles I use SpriteBatch (You can see that in ground.lua).
Thanks.
Artifacts in tiles
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Artifacts in tiles
- Attachments
-
- gtp1.love
- source
- (252 KiB) Downloaded 115 times
Re: Artifacts in tiles
I beleive this has to do with aliasing. Try moving camera strictly to integral positions.
Re: Artifacts in tiles
When you move your camera to a position that makes the images fall just on the edge of a pixel, OpenGL wants to use the color of the neighbouring pixel (outside of the tile) in the spritesheet. This is expected behaviour.
One solution is to make sure that the images always line up on the pixel. For example, you could change your scene update code to this.
Of course, this is a bit ugly and won't work if you start rotating. The better solution then is to pad each of your tiles with a 1 pixel border with the color of the neighbouring pixel. This will give the expected result in all situations.
One solution is to make sure that the images always line up on the pixel. For example, you could change your scene update code to this.
Code: Select all
local sx, sy = love.graphics.getWidth(), love.graphics.getHeight()
camera:move(math.floor(dx/2*sx)/sx, math.floor(dy/2*sy)/sx)
Shallow indentations.
Re: Artifacts in tiles
Thanks for the answers. Maybe there's another way to draw tiles? When opengl knows what near tile.
Re: Artifacts in tiles
OpenGL draws your tiles as a textured triangles. Due to aliasing, a fragment of a triangle can either occupy a whole pixel, or not occupy it at all. But decimal values of edges' positions and texture coordinates are maintained as decimal, and since there's no aliasing for textures (by default), on the aliased edge it can render slightly beyond desired texture edge, resulting in overlapping with next tile. Think of it as if your tile was a slot in cardboard with a wallpaper beyond it. The wallpaper moves freely, but the slot can only "jump" through 2 inches at once.
- slime
- Solid Snayke
- Posts: 3170
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Artifacts in tiles
Tools like http://www.codeandweb.com/texturepacker can automatically add the padding Boolsheet's talking about to your sprite sheet for you.
Re: Artifacts in tiles
I understand why. I thought maybe it makes sense to create a texture on the entire screen. So opengl will know which pixel nearby.
Re: Artifacts in tiles
thanksslime wrote:Tools like http://www.codeandweb.com/texturepacker can automatically add the padding Boolsheet's talking about to your sprite sheet for you.
- AntonioModer
- Party member
- Posts: 202
- Joined: Fri Jun 15, 2012 5:31 pm
- Location: Belarus
- Contact:
Who is online
Users browsing this forum: Hugues Ross and 5 guests