Seanba / Tiled2Unity

Export Tiled Map Editor (TMX) files into Unity
Other
497 stars 120 forks source link

Layer Sprites glitch while exported to Unity #123

Open beuted opened 7 years ago

beuted commented 7 years ago

I've got this rendering issue (on only one Layer it seems) in my unity project: Some glitches near the edge of the background tiles like the next tile was overflowing on the current-tile for a fraction of a pixel :(

image

Here is what I've done: I've got a tiled project with 2 layers "Background" and "Ground"

image

Background have the following properties:

image

And Ground:

image

I haven't set the unity:scale property and I'm exporting with the --textel-bias=0 property. In Tiled2Unity I'm using Pixel Per Unit: 1

My tileset properties in Unity ar ethe following: image

Tiled2Unity v1.0.12.3

Does sbdy have an idea on what I've done wrong ?

Seanba commented 7 years ago

Those are seams and they are fairly common with tile-based projects in Unity. There's a couple of things to check:

  1. Do you have any warnings in your Unity Console output window? It may warn you that anti-aliasing is enabled. This is the #1 cause of seams.
  2. Are these seams appearing in both your Game and Scene windows? Under some conditions, seams will always appear in your Scene window. It's only really a problem if the seams show up in your Game window where it uses only the shaders for your project.
beuted commented 7 years ago

~Thanks for the quick answer.~

~I don't have any warnings on the unity console no, only my Debug.Logs (could they be hidden ?). If it was the root cause how could it be disabled ?~

~The glitch appear in both my game and scene window yes.~

~At first as I said I thought it was appearing on only on the background layer but it's in fact on all layers so it does not seems to be layer dependent.~

Never mind read below :)

beuted commented 7 years ago

Ok it seems to be anti-alising indeed I've changed my camera rendering path to "Deferred" and it's much better

Although with my perspective camera it's still glitching when it moves but it as obviously no link with Tiled2Unity. So unless you have some other tips for me I think you can close this issue I'll ask on proper Unity related thread.

Thanks a lot and sorry for the trouble :)

killazilla54 commented 7 years ago

I am having a similar issue. However, I am using an orthographic camera, not perspective so the Deferred option does not work for me.

Was working with an older version (2 releases ago) and only started showing after I updated to the newest release on the itch app.

screen shot 2017-08-26 at 4 13 25 pm

Seanba commented 7 years ago

Instead of messing with the camera forward/deferred settings I would disable anti-aliasing in the quality settings. Can you give that a try?

killazilla54 commented 7 years ago

Ok so I was using Unity 5.5, anti aliasing removed 95% of issues but was still seeing small seams when the camera would move, both in editor and in a built version(mac). Imported a copy of the project into Unity 2017, turned off AA.

Baked (Mac): When built I don't see any issues so far. Seems to have worked.

In Editor: again 95% fixed, now with big seams (see image).

Thanks for the help. Will attach image of the editor bug just for your record. Glad its working in built versions at least. Great tool! screen shot 2017-08-29 at 4 10 43 pm

beuted commented 7 years ago

Hey I'm curious where you removed antialiasing, I tried but could not find the option. I thought is was the "Deferred" option on the camera at first.

Muskya commented 7 years ago

You can find the Antialiasing option in Edit -> Project Settings ->Quality in case you didn't find it since then. x)

Muskya commented 7 years ago

I kinda get the same issue I guess. I mean, I had those sort of lines all around my sprites which is something I corrected by disabling the anti-aliasing. Unfortunately, there is still a problem remaining. I got some sort of cut-lines on specific spots on my map, but they only appear when I start the game. Everything is clean on the Scene view.

In the Scene View: map1git

In-Game: map2git

if you need me to paste some of my tilemaps.tmx / quality / project properties, just tell me. ;p

Seanba commented 6 years ago

I updated the Tiled2Unity documentation in order to help with seams. The only 100% foolproof solution requires a change to your tileset images.

http://tiled2unity.readthedocs.io/en/latest/fixing-seams/

PicosePablo commented 6 years ago

Are you still working on this bug or that's the only solution is going to exist?

matthuston commented 6 years ago

It's not really a bug, when the texture has anti-aliasing there is some imprecision in the rendering. You either turn off anti-aliasing or tweak your tile textures to compensate for the pixel or two that is the issue.

PicosePablo commented 6 years ago

Ok, I found a solution!!!!!!!!!!!!!!!! First of all, go to Edit->Project Settings-> Quality and disable Anti Aliasing. Ok, now you will see that the artefacts will be reduced, but not at all. Then you have, in your Prefab a transparent GameObject (ex: CaveMap->floor->cave_transparent), u have to go to the "TILED TEXTURE" component inside it and turn ON the Pixel Snap, don't worry about the editor if u click "play" this lines will disappear!!!!!!

Seanba commented 6 years ago

Hi there. The Pixel Snap setting forces your vertex positions to be aligned with pixel grid values. This can reduce the appearance of seams under some conditions but it can also make it worse. It will depend on your viewport size, ortho camera size, camera position, and "pixels per unit" settings.

(Note you would have this same problem if you were to use sprites in Unity that had animations right up next to each other in a spritesheet.)

The only real 100% solution is to pad your tileset textures but if your back was up against a wall then using the --texel-bias option in Tiled2Unity is a good quick fix.