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

Investigate Unintended Screenshot Antialiasing #2421

Closed
eonarheim opened this issue Jul 17, 2022 · 4 comments · Fixed by #2428
Closed

Investigate Unintended Screenshot Antialiasing #2421

eonarheim opened this issue Jul 17, 2022 · 4 comments · Fixed by #2428
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior

Comments

@eonarheim
Copy link
Member

Steps to Reproduce

See discussion thread: #2415

Excalibur screen shots seem to apply an AA effect that wasn't present on the game screen at the time the screenshot is taken.

Before screenshot, crisp pixels

image

After screenshot, some unexpected AA effect.

image

Seems to only affect the moving Actor in this example?

Expected Result

The screenshot should look exactly like the frame as it was displayed, including any relevant AA settings.

Actual Result

Some unintended AA is being applied.

Environment

  • browsers and versions: Chrome 103
  • operating system: Win
  • Excalibur versions: 0.27.0

Current Workaround

None

@eonarheim eonarheim added the bug This issue describes undesirable, incorrect, or unexpected behavior label Jul 17, 2022
@mattjennings
Copy link
Contributor

Here's a repro: https://codesandbox.io/s/excalibur-antialias-screenshot-zbw94v

At the bottom you'll see new ScreenShotter({ hires: false }) - changing that to true will fix the antialiasing. I think this is probably not a bug though. It only happens if the character is on a half-pixel. If engine.screenshot(false) produces a screenshot at game resolution, then it makes sense that it gets antialiased.

The workaround is to take the screenshot at hires so it matches the canvas resolution, but you just have to do a bit of extra work when drawing to scale it back down according to window.devicePixelRatio (as shown in the repro).

Anyway, all that to say I don't think there's anything to do here, I just hit an edge case with an acceptable workaround.

@eonarheim
Copy link
Member Author

@mattjennings I've found that matching the internal screenshot canvas to the current screen smoothing seems to produce more desirable results out of the box (#2428). I think this makes the workaround unnecessary?

Let me know what you think! I'm still poking around, it is also resisting being tested for some reason

@mattjennings
Copy link
Contributor

@eonarheim oh! very interesting. I just gave it a try and I'm not seeing any antialiasing like before, so I would say this is a good fix!

@eonarheim
Copy link
Member Author

Thanks for checking it out! I'll have some time today to hopefully get it merged 👍

eonarheim added a commit that referenced this issue Jul 23, 2022
This PR adjusts the screenshot smoothing (antialiasing) to match the current game's screen.

Closes #2421

## Changes:

- Match screen AA in screenshot canvas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants