Lines between my tiles?

I have seen a strange issue both in viewing the examples provided with Lime in the viewer and with the map I’ve created. What I have noticed is that lines appear between some tiles, they also appear and disappear as the screen moves. It looks as if the tiles are off by one pixel in some areas or such. I’m not sure if this is a known issue since I’m seeing it in the viewer examples.

Here is a screenshot of what I’m talking about:

http://imageshack.us/photo/my-images/21/linesbu.png/ [import]uid: 64619 topic_id: 10803 reply_id: 310803[/import]

These lines are generally caused by the content scaling, make sure the resolution in config.lua is correct for your device. [import]uid: 5833 topic_id: 10803 reply_id: 39287[/import]

Just to add to this; make sure your images are an EVEN number of pixels by an EVEN number of pixels.

This issue drove me mad as a newbie :wink:

Peach [import]uid: 52491 topic_id: 10803 reply_id: 39322[/import]

And to add to that further, also try to make sure your images are powers of 2 :slight_smile: [import]uid: 5833 topic_id: 10803 reply_id: 39325[/import]

Ahh this makes sense, I had this happen with 1 of my images as well. Thanks for the advice Peach and Graham. [import]uid: 31262 topic_id: 10803 reply_id: 39336[/import]

@Graham
I was seeing this in the viewer example (as shown in the screenshot). I am developing for android devices. What should I set the width, height to in the config.lua for android? In my application I believe it is w=480 h=800

@Peach
My image tiles are even. I used 64x64 grid in Photoshop. It looks fine in the Tiled application.

@Graham
64x64

Once I get this resolved I should be good to go. Other than these lines showing up it is working great.

Thanks! [import]uid: 64619 topic_id: 10803 reply_id: 39338[/import]

Well I just noticed that if I zoom in on the simulator the blinking lines go away. But I tried it on my phone and they are still there. Hmmm… [import]uid: 64619 topic_id: 10803 reply_id: 39394[/import]

Sweet, it looks fine now. I changed the scaling to “none” in the config.

Thanks for the help!

application =
{
content =
{
width=480,
height=800,
scale = “none”,
},
} [import]uid: 64619 topic_id: 10803 reply_id: 39395[/import]

Glad to hear it, look forward to seeing the completed project! :slight_smile:

Peach [import]uid: 52491 topic_id: 10803 reply_id: 39449[/import]

Has this issue reemerged with the latest Corona builds as I cannot seem to fix this problem and I have tried everything lol. I have tried the latest build and still the same issue

* Have modified the .config file with all variations
* Have added @2x tilesheet and same issue, works fine on 3GS but when built/viewed on iPhone4 can see the lines.
* The files are from the tutorials are the same look fine on iPhone3G but lines on iPhone4

I am trying to develop a game for both iphone3 and iphone4 and simply cannot get past this problem for the last two weeks which is becoming frustrating.

Can someone please help or advise what else I can do ? [import]uid: 40417 topic_id: 10803 reply_id: 43962[/import]

Are you able to send your project to support@justaddli.me and I can then see if I can solve the issue? [import]uid: 5833 topic_id: 10803 reply_id: 46535[/import]

OK this problem is caused when you are trying to display a tile at a larger resolution than it actually is, so yeah it normally shows up from content scaling.

The problem is the graphic itself and how Corona interpolates the images (and in fact several of us have petitioned to be able to remove this interpolation which would remove this problem, albeit present others).

Basically while an image is mapped to the screen on a 1 to 1 pixel basis or smaller, all is fine.
When you show the tile onscreen bigger than it is, corona chooses to try to be helpful, and smooth the graphic. By which I mean say you have in your tile a white pixel next to a black pixel, but because of zooming this takes up 3 pixels, the middle one would be grey - interpolated from the white and black.
Now this is lovely for many things, but…

Well, most tile sets have the images right next to each other in the graphic, which means that when you zoom a tile, it is interpolating from its edge pixel, into the edge pixel of the tile next to it in the source graphic.

Ruh-roh!

Fear not though, my friends, for there are solutions. I mean apart from bashing your head against the wall.

Bear in mind this won’t look perfect - there really is no proper alternative except for manually choosing a correctly sized source image for the resolution of the device, but you can work around it.

Basically you need to re-lay-out your original image and do some magic in photoshop or whatever.
Let’s say you have a 512x512 image with tiles of 50 pixels each.
What you need to do is space them out, giving each tile its own seperate 1 pixel border on every side.

So the top left tile would be at 2,2 instead of 1,1 and the second would be at 54,2 instead of 50, 1. The next at 106, 1 etc.
Then, and this is the tedious part…

you must duplicate each tile’s edge pixel into the adjacent space available for it, followed by filling in the corner pixels of the borders with the corresponding pixel of the tile.

Boring eh?

So basically each tile now has its border repeated on each side by 1 pixel.

What this means is that at least when the tile comes to be zoomed in-game it will interpolate with the same colour as its own edge, and you won’t get those silly lines cropping up.

Now, it won’t look 100% correct either! But it won’t look massively wrong.

A couple of further tips to avoid weirdness, is to avoid scrolling in fractions of a pixel. Whenever you come to draw a screen, always make sure the view is math.floor() or math.ceil() to an individual pixel of the device resolution. Bear in mind this may necesesite NOT using one of corona’s inbuilt zoom modes (which was the first thing I ditched anyway as soon as I realised the limitations). If you don’t do this, you’ll see the edges of tiles flicker differently to the scrolling, simply because edge drawing of a tile is clipped to pixel boundaries, but the interpolation of the image within the tile itself is not.

@danny - because your project is just for iphone and iphone4, you have the luxury of having two very simple resolutions to work with.
What you need are 2 versions of the tile sheet image, the second one being scaled up twice as big (my suggestion would be to do it in photoshop WITHOUT bilinear or trilinear filtering, or it’ll look wrong again!). Then work out which device you are on manually, and load the appropriate image, doubling the sprite sheet parameters as needed (width and height of each frame).
Since you’ll now always have the right image according to screen resolution, you should never see those lines. [import]uid: 46639 topic_id: 10803 reply_id: 78400[/import]

Thank you for the very thorough explanation! I hope Ansca can get something sorted for this. [import]uid: 5833 topic_id: 10803 reply_id: 78980[/import]

Hey everyone I am having the same problem. I building for android devices hopefully for both tablets and phones, and well the problem I have is there is too many different phone resolutions out there for me to just manually apply the tile sheet and map file. Is there another solution for this? And ill add that not only will this problem occur when trying to scale an image to a bigger resolution then what it is supposed to be but also happens when you are scaling down the resolution. [import]uid: 35973 topic_id: 10803 reply_id: 82630[/import]

Rakoonic, thank you SO much for that extremely helpful post. My partner and I have been going a little bit crazy with the white lines between our tiles, and your suggestion of adding the border in the image made the situation a thousand times better. One of the best posts I’ve ever seen from a community member! [import]uid: 144846 topic_id: 10803 reply_id: 111191[/import]

@rakoonic, great explanation! In fact, I came across a comment elsewhere that this is “game art rule #5”.

This is a universal OpenGL problem, not a unique Corona one. Anytime you are packing images onto a single texture (aka spritesheet/imagesheet), you are going to have this problem.

The good news is there are tools that help you deal with this. TexturePacker, for example, has an “extrude” option that repeats the borders of each tile/image in a spritesheet to address this exact problem.

I did a quick test using TexturePacker, and setting the “extrude” value to 2 does add a 2 pixel border that repeats the edge of a given tile. The generated size of each tile is the same, but you get the necessary padding so that the interpolation doesn’t bleed into the adjacent tile/image. [import]uid: 26 topic_id: 10803 reply_id: 112066[/import]

Addendum:

In terms of how this works with tools like “Tiled” (the tile map generation tool that Lime recommends), you’d want to set the margin/spacing to match the repeated border width used in tools like TexturePacker.

@Graham, I’m sending you a note offline about this to confirm. [import]uid: 26 topic_id: 10803 reply_id: 112067[/import]

With todays daily build, that introduced the ‘border’ property to ImageSheet, this should no longer be an issue, right?

EDIT: Worked like a charm for me! :slight_smile: [import]uid: 129450 topic_id: 10803 reply_id: 114311[/import]

Yes, the one gotcha is that you’ll want to create the image sheet correctly when you use ‘border’ so the image border is repeated correctly (as I mentioned above).

If you reuse an old one without the padding, your tile will be smaller on each side by the thickness of the border you specify. [import]uid: 26 topic_id: 10803 reply_id: 114362[/import]

Where is the border property covered in the documentation? Can’t seem to find out anything about this…(EDIT: Oh, it’s not.)

  1. I’ll file a bug somewhere; not having border listed in the docs is a shame for the new documentation platform.

  2. I think a clearer instruction is needed for this to actually be a practical solution; I tried applying borders and had no luck getting imageSheet to work. Sadly this problem is basically as complex or more than creating masks, and there’s already a page of Corona documentation for that!

a) It’s not clear at all which Tiled tile set settings must be made. Spacing? Margin? Who knows?

b) I think Corona is choking on the file being power of 2 but because of the border cannot fill image with tiles (you get a bunch of blank space on the side that isn’t quite one-tile wide)

Texture packer is an interesting idea but also totally untenable for tile work. Faster to do the pixel pushing in Photoshop than labor through a complete tile set disassembly in the hopes that it might make one file that can be used in Tiled.

  1. Setting borders requires editing a core lime file, so that’s probably something for Graham to expose in the map loader.

I think the problem is solvable for Lime but will take some time with a separate, raw project to figure out since Lime, Tiled, and Corona all need different changes at different levels for this to work. [import]uid: 41884 topic_id: 10803 reply_id: 115940[/import]