flixel
flixel copied to clipboard
Serious floating-point artifacts on CPP FlxTilemap & FlxSprite

I made all transparent tiles in my tileMap bright green to highlight the issue. The boundaries of some tiles are showing pixel data from their adjacent neighbours.
(1) This only occurs on some resolutions. Try lots of different resolutions. (2) This occurs infrequently; best way to "find" it is by moving slowly in x and y axis. Most likely some floating point issue.
Using latest version from github.
Noticed that too. I guess normally you would use tileScaleHack of your FlxTilemap but that doesn't improve it. I have found a workaround by using the PixelPerfect Scalemode.
Seems to be fairly easy to repdroduce (Project Jumper demo for example).
@Beeblerox Any idea what could be causing this?
This might not be a bug with HaxeFlixel, check out this GameMaker article on this issue and how to prevent it: http://www.yoyogames.com/tech_blog/8
@gamedevsam I think this is a different issue than the one that's described in the article. We also have issues with tilemap scaling on native targets, but that's a different problem and fixed by the tileScaleHack.
I'm having a similar issue with the Linux version of my game. Strangely, this only occurs in Linux (Ubuntu 14 64-bit, running from a flash drive via UNetbootin).

I also noted the same issue in Flappybalt, I'll grab a photo when I can. This is not limited to tilemaps, however. Don't Move uses an image atlas, which could explain the problem, but Flappybalt doesn't.
edit: Note that setting pixelPerfectRender to false and using software rendering (by setting --window-hardware=false as suggested by @jgranick) both had no effect.
It happens in my game as well. I'll post a screenshot soon. I'm using Windows 7 64-bit, and compiling the game to Windows. I have two versions, a server and a client. Both versions have different camera settings, and the issue only happens on the client version. I'll post the two camera settings soon, maybe it will clarify the issue.

Actually I just realized that it happens in both the client and server versions, but it's less apparent in the server version. In the client version it happens from time to time when the camera is moving, but the issue only appears for a split second, then it's back to normal. I was lucky enough to hit print screen as it happened.

You can see here that the black lines are actually edges of the tile's adjacent tile in the tilemap:

gamedevsam's link is definitely relevant. I think it identifies pretty well the problem, and it can be resolved with spaced tilemaps. Can HaxeFlixel load spaced tilemaps?
Can HaxeFlixel load spaced tilemaps?
Yes. https://github.com/HaxeFlixel/flixel/issues/434#issuecomment-34834484
Okay, adding a spacing of 2px and the smearing they talk about in the link solved the issue.
My issue doesn't seem to be limited to tilemaps, should I open a separate issue? If anyone else has access to a Linux environment, let me know, and I can send you the Linux build above (or you can just load up Flappybalt v1.1).
@steverichey This issue isn't limited to tilemaps for @cwkx either.
I have the artifacts too and I don't use any tile spacing. I could bet that this is a Float to Int convert issue.

I guess the GM solution might work but is there any chance to automate this process even for tilemap textures without spacing? Since I am trying to port a lot of tile maps I've done without. And that would be quite an overkill to handle manually.
I believe that my issue is unrelated to this. I suspect that the graphic issues shown above have to do with improper drivers.
For those wondering how to reposition tilemaps: http://registry.gimp.org/node/24816
Thank's ... Tried that script with Gimp 2.8 it didn't work for me (image sizes stayed the same), but I get the point - one 'could' script the whole level design in PS/Gimp then print that to paper - cu t and re-size it and scan it back in.... sorry... just no solution for me. And since my editor doesn't support nor need spacing for things to work, I'd have to use 2 sets (one for the editor and one for HF - dats stupid and rather a no-no) - can't this maybe be resolved by adding some 'nearest neighbor scaling maybe or optionally using Ints instead of Floats for the scroll/scale or whatever actually causes the issue ... cus I don't understand it -if I have a 16x16 tile then this thing should BE 16x16px and not 16.01x16.01 =/
or is it 'the NeW Way' to handle tilemaps now? With clamping and spacing? I'd have loads of awkward image sizes and recalculating to do on that. Sorry, I'm a dick.
Whoa calm down, this is an open-source project where people contribute their time and efforts for free. If there's a bug it should be reported and then fixed by whoever feels like fixing it. I'll try to add a loadNativeMap function which will act exactly like the loadMap function, but the asset passed to it will be transformed into an appropriate tilemap at runtime: i.e.: 1px border, 2px spacing, and right-most and bottom-most pixels extended. I'll try and have this done by Sunday. That way you can use your assets the way you always do, I admit that I don't want to need two versions of a tileset either.
@Ohmnivore Maybe it's be better to add a FlxBitmapUtil.addSpacing() to pre-process the asset before passing it into loadMap()? That approach seems more flexible (could also be applied to sprites for example).
Good idea, I forgot about sprites.
Hey guys, just made a first version: https://gist.github.com/Ohmnivore/41eaca877d202b875b65 To my understanding FlxSprite also accepts a TextureRegion for loadGraphic, so this can be used to fix the issue for sprites and tilesets. For now my code assumes that frames/tiles are square, I'm gonna add variable width and height support in like 15 minutes.
ex: map.loadMap(mapdata.arr, TestFeatures.artefactFix("assets/images/gridtiles2.png", 16), 16, 16, 0, 0, 1, 1);
Okay, updated that gist to the new version. Now you can pass tile width and tile height. ex: map.loadMap(mapdata.arr, TestFeatures.artefactFix("assets/images/gridtiles2.png", 16, 16), 16, 16, 0, 0, 1, 1);
@Ohmnivore Sorry for being demanding. I just talk that way. The gaming biz made me that way, of course I know that this isn't a commercial product where a 'customer' would demand progress. I saw a serious issue and didn't want to lay that off to a toolchain and sprinkled in some sarcasm. I guess it is in every ones interest to make this work. And at the time being, this is all I can do - point out things and share my experience. I'm just an artist working with this.
I'll look at that update later or when you are happy with it. Sounds usable.
I'm satisfied with the gist, I don't think I'm going to add anything. I haven't spotted any issues with it yet, and seems to work fine. BTW I have a terrible sarcasm detector. No hard feelings.
Hi, I think I have a similar case of this problem but using sprite's makeGraphics.
I'm using sprites to debug my BSP Tree algorithm and noticed that in some cases one or more sprites are printed with a tilt of one pixel. As you can see in this ss (i drawed a white box behind to spot the tilts more easily):

Who can I apply @Ohmnivore 's soluction in my case? Or there is any flixel/haxe/openfl release with a correction for this problem coming in a near future?
@RawArkanis Any chance you could share a simple test case for that? It may or may not be the same issue, but I'm curious all the same.
@JoeCreates, sure! Here are a project with the relevant code: https://hostr.co/qNqCntSHi3RL
First I thought it was a code mistake, but this code work perfectly on flash target and give problems on neko and windows.
RawArkanis this looks awfully similar to the problem I had. This can fix it: https://gist.github.com/Ohmnivore/41eaca877d202b875b65
This might also be related?
Apparently this issue affects Kindle Fire HDX 7 (3rd Gen), and Kindle Fire HD 7 (2nd Gen). Recent fixes resolved it for iOS, Mac, and Linux, so this was news to me. Image via Amazon:

Hey guys, I'm now developing for Android and testing on my tablet. I still get this issue, it's not a game breaker but it sure is annoying. My old method of dealing with it: https://gist.github.com/Ohmnivore/41eaca877d202b875b65 somehow doesn't work anymore. I'm wondering why, but I'm also wondering how you guys got around the issue?
@Ohmnivore does it not working or it not compiling?