Aliasing problem

238 views
Skip to first unread message

Vasco

unread,
Jan 7, 2016, 6:57:19 PM1/7/16
to haxef...@googlegroups.com
I am trying to make a desktop game, but I'm having trouble dealing with aliasing issues.

I have set <window if="desktop" antialiasing="4" />, FlxG.camera.antialiasing = true, and FlxObject.pixelPerfectRender = false.

I made a short video which shows the issue here: Aliasing problem

Each of the squares is a FlxSprite, and when moving them, the pixels that compose the sprite change size (it's very apparent where the squares are touching). The issue is not caused from the sprites being tiled, it's possible to see the pixels of a sprite slightly change size when alone.

I also don't think I can avoid using antialiasing, because I'm creating the assets for 1080p, but want to be able to downscale to other resolutions, and it looks even worse when downscaled without antialiasing.

Is there anything I can do to make this look better?

MegaLeon

unread,
Jan 7, 2016, 7:16:04 PM1/7/16
to HaxeFlixel
You could try FlxG.stage.quality = flash.display.StageQuality.BEST;

Vasco

unread,
Jan 7, 2016, 7:32:52 PM1/7/16
to HaxeFlixel
I tried, but it doesn't seem to make a difference :(

MegaLeon

unread,
Jan 8, 2016, 6:40:46 AM1/8/16
to HaxeFlixel
what are your game width / height values and your window size? Might be a problem of bad scaling

Vasco

unread,
Jan 8, 2016, 1:43:04 PM1/8/16
to HaxeFlixel
Ah, that may be the problem :)  I was using a small window (800x450), but then resizing it to make it bigger. I thought that the bigger window size just made the problem more apparent, but if I start off with an already bigger window (such as 1200x675), the problem mostly goes away. There seems to still be a little aliasing, but I'm not sure if it's my fault, since it seems to happen only when the moving object changes direction. Anyway, it's much better if I don't resize.

Is there anything I can do to make it scale better? I can disable window resizing, but I need to be able to at least switch between window and full-screen modes.

Ohmnivore

unread,
Jan 8, 2016, 2:45:18 PM1/8/16
to HaxeFlixel
Assuming you're using the dev branch.

For your tilemaps:
tilemap.useScaleHack = false;
tilemap.pixelPerfectPosition = true;
tilemap.pixelPerfectRender = true;

When loading a map, instead of passing the asset directly do this first, and then pass it to loadMap:
var img:FlxTileFrames = FlxTileFrames.fromBitmapAddSpacesAndBorders("assets/images/researchstation.png", new FlxPoint(16, 16), new FlxPoint(2, 2), new FlxPoint(2, 2), null);

The camera:
FlxG.camera.pixelPerfectRender = true;

Use this for sprites too, i think they suffer the same issues.

Vasco

unread,
Jan 8, 2016, 3:56:19 PM1/8/16
to HaxeFlixel
Thanks, but I'm not actually using tilemaps. Since I will need a lot of control over each "tile", I felt that using FlxSprites would be easier.

I am not using the dev branch, but version 3.3.12.

Using pixelPerfectRender on the sprites seems worse to me, I think I need to use antialiasing because the native resolution of the game is 1920x1080, and I want to be able to downscale to lower resolutions.

Ohmnivore

unread,
Jan 8, 2016, 4:24:31 PM1/8/16
to HaxeFlixel
Oh if you're not on dev then check the last few messages on this thread: https://github.com/HaxeFlixel/flixel/issues/911# , you'll find a different fix that i used a while ago with the master branch.

I haven't tested my fix on the newest master version but i think it should work. It can and should be applied to both FlxSprites and FlxTilemaps (they're both affected by the exact same issue).

Vasco

unread,
Jan 12, 2016, 1:34:26 PM1/12/16
to HaxeFlixel
I tried your fix, it seemed to do what it was supposed to (because I can change the size of the texture region of the sprites by changing the width/height of artifactFix() ), but the problem remains. Maybe the problem I'm experiencing is a different issue?

Here's a video of how it looks now without resizing the window. Not as bad as with resize, but still there. It seems to happen only when moving to the left now, but that seems to change depending on the sprite I'm using.
Reply all
Reply to author
Forward
0 new messages