Draw TiledMap: Strange Borders around Animated Tiles

Hey guys!

I am using Monogame.Extended for my game. One big benefit is the unbelievable easy way to draw a Tiled Map.
As i searched through the code of the Tiled namespace i discovered the support for Animated Tiles and testet it immediately after.
First, I pretty much copy pasted the Demo code for starters, which means I created a Camera2D and a ViewportAdapter to easily move on the map.

Now… when i draw the map and move to the animated Tiles on the map (which are some water coast tiles and a waterfall)
i experienced some weird box-borderlines around each animated tile:

that’s what it looks like in Monogame when drawn.
This is zoom 1.0f, so original size … the lines naturally get worse when zoomed :frowning:

this is what Tiled shows… even zoomed.

Just wondered if one of you guys has any idea whats happening here…
if its a known issue or … maybe it’s a settings issue of some kind :confused:

I’d be really glad if you could help me :slightly_smiling:

These types of artifacts are usually from rendering using bilinear filtering. The artifacts come from the filtering blending to neighbouring texels just outside the texture if on a texture atlas, or wrapping around to the other side of the texture when the texture exists by itself. The screenshot from Tiled is obviously using no filtering.

Try rendering using point filtering instead of the default bilinear filtering.

1 Like

Thanks for the answer!
Now that you say it … this might really be the problem.
Now I am looking for a way to change the default SamplerState… looked around for a bit and came to a call:

GraphicsDevice.SamplerStates[0] = SamplerState.Point;

which leads to an exception that i could not “modify a default sampler state object.”
… Further research didnt quite get me far though ^^"…
Do we have a common way to … change default rendering? :hushed:

EDIT:
I searched a bit more and found a post by tgjones that i had to set the whole object like:
device.SamplerStates[0] = new SamplerState { Filter = TextureFilter.Point, … };

Srry for bothering :smiley:
I will test this now :slightly_smiling:

EDIT2:
It worked :slightly_smiling:
well i did not change the default rendering though,
i called a spritebatch.begin(…) and passed it the SampleState i needed ^^

Thanks again for the help Konaju! :smiley:

Thanks for that @KonajuGames. That is indeed an easy solution.

We’ve been tossing around the idea of re-writing the Tiled renderer to render the tiles as a mesh just like you would in a 3D terrain engine. This should get around many of the problems with the existing renderer including this one.

At this stage it’s just talk though, nobody has started implementing anything yet.

EDIT: Here’s the related issue.