mfessenden / SKTiled

Swift framework for working with Tiled assets in SpriteKit
Other
261 stars 33 forks source link

Large tile maps not rendering correctly #24

Closed Relequestual closed 5 years ago

Relequestual commented 5 years ago

I'm testing out this library as a possible means to load in default maps and manage maps for a biz sim game. The MacOS demo application seemed to work OK with the sample tilemaps.

I tried loading in my own tilemap (50x50 at 64px), sometimes it loads fine, but others it only loads to y31 graphically. I can still see the mouse over triggers change for the lower part of the image, even though I can't see it. When i click "show grid", this then changes so only x18 and beyond are shown, but all of y is shown.

Seems pretty weird to me. It's an intermittent issue, so it seems. (I'm sorry.) Here are the attached tilemap and pallet file.

tileset.zip (I had to upload them as a zip because of github restrictions.)

I don't want to spend time intergrating this tilemap solution into my current setup if there are problems with maps of that size.

I'm running version 1.21. Running on MBP 13" 2017 on MacOS 10.13.6

mfessenden commented 5 years ago

It looks as if there's a glitch with SKEffectNode objects in SpriteKit, which the SKTilemap and layer objects inherit from. I haven't seen it happen yet, so I'll have to figure out what's happening here and possibly talk to Apple about the bug.

To fix it, load your map in the demo application and disable the effects rendering option and you should see the entire map (select Map -> Render Effects... or press the 'e' key).

Relequestual commented 5 years ago

Thanks. Noted, I'll try that. Obvioulsy I'm not running on the latest version of MacOS, so may already be fixed.

On the up side, when I intergrated a basic tile map into my current ios game, it all shows up fine, and I don't notice any graphical issues (although performance is another matter ;) )

mfessenden commented 5 years ago

After looking into this some more, it appears as if this is a SpriteKit limitation. The SKEffectNode renders its children into a framebuffer, but caps the texture size to 2048x2048. If I resize your map to 32x32 tiles and enable effects rendering, it renders as expected.

The SKTilemap node is subclassed from SKEffectNode because enabling effects is an easy way to get rid of the cracks that can sometimes appear between tiles with a minimal performance hit, and with effects turned off it's basically just another SKNode.

I'll look into getting the map to throw a warning on these occasions in the next release and add a mention in the docs.