Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pixel Anti Aliasing #3149

Closed
1 task
dbroadhurst opened this issue May 6, 2024 · 5 comments
Closed
1 task

Pixel Anti Aliasing #3149

dbroadhurst opened this issue May 6, 2024 · 5 comments
Labels

Comments

@dbroadhurst
Copy link

What happened?

When I arrange sprites in a grid and see background pixel appearing due to anti aliasing

Screenshot 2024-05-06 at 8 53 12 AM

I tried the following without any improvement

sprite.paint.isAntiAlias = false;
sprite.paint.filterQuality = FilterQuality.low;

What do you expect?

Expect to see no unexpected visual artifacts

How can we reproduce this?

Arrange sprites in a grid. I suspect this is a known issue but can't find a way to fix.

What steps should take to fix this?

No response

Do have an example of where the bug occurs?

No response

Relevant log output

No response

Execute in a terminal and put output into the code block below

Output of: flutter doctor -v

Affected platforms

All

Other information

No response

Are you interested in working on a PR for this?

  • I want to work on this
@dbroadhurst dbroadhurst added the bug label May 6, 2024
@spydon
Copy link
Member

spydon commented May 6, 2024

It is this issue: flutter/flutter#14288
Are you sure it is happening on all platforms for you? Even Impeller backed ones?

Erick has wrote a bit about it here:
https://verygood.ventures/blog/solving-super-dashs-rendering-challenges-eliminating-ghost-lines-for-a-seamless-gaming-experience

@spydon
Copy link
Member

spydon commented May 6, 2024

There's also some discussion about it in here: #1152

@dbroadhurst
Copy link
Author

dbroadhurst commented May 6, 2024

I forced Impella on macOS, Android and iOS and the lines have gone but now getting unexpected double lines. I think Bilinear filtering is still on since I can see AA where the pink and orange meet.

Screenshot 2024-05-06 at 11 33 26 AM

Seems to have no effect on the rendering

sprite.paint.isAntiAlias = false;
sprite.paint.filterQuality = FilterQuality.none;

To give more context this image is made from 64x64 spritesheet images.

I think the double lines are coming from bilinear interpolation where the edges meet.

@dbroadhurst
Copy link
Author

I got AA working. Turns out setting AA in the constructor works but setting the instance does not work. Impeller seems broken right now.

Works

class BuildingBlock extends SpriteComponent
    with HasGameRef<PlunderGame>, CollisionCallbacks {
  BuildingBlock({required Sprite sprite, required double x, required double y})
      : super(
          sprite: sprite,
          position: Vector2(x, y),
          size: Vector2(32, 32),
          paint: Paint()..isAntiAlias = false,
        );
}

Does not work

  var sprite = spriteSheet.getSpriteById(block);
        sprite.paint.isAntiAlias = false;
        sprite.paint.filterQuality = FilterQuality.none;
        _world.add(BuildingBlock(
          sprite: sprite,
          x: blockX,
          y: blockY,
        ));

@spydon
Copy link
Member

spydon commented May 7, 2024

Right, that is because the component is using its own paint object, not the one inside Sprite, so you could also set it with component.paint = ... for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants