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

Should vector skins/costumes always be rendered with a resolution greater than their screen-space dimensions? #620

Closed
adroitwhiz opened this issue May 16, 2020 · 10 comments · Fixed by #649

Comments

@adroitwhiz
Copy link
Contributor

Expected Behavior

Vector skins/costumes should appear sharp at all scales.

Actual Behavior

Vector skins are internally represented by a series of textures at various resolutions. These textures are allowed to appear on-screen at up to 1.5x their resolution, meaning that at worst, 1 "texture pixel" will be magnified to 1.5 "screen pixels". This results in vector sprites often appearing blurry:
image

This blurriness is particularly bad for things like text, which results in issues like #558.

This could be changed so that the textures must always be at a higher resolution than, or the same resolution as, their "screen-space" dimensions. This would consume more RAM, but the improvement in visual fidelity may well be worth it.

Keep in mind that until last October, vector costumes were rendered at least twice as large as they should have been on high-DPI devices like phones, so this shouldn't have an unprecedented RAM impact.

Steps to Reproduce

  1. Create a new project
  2. With the default cat sprite selected, click on the "change size by 10" block in the Blocks Palette while observing the cat sprite
  3. Notice that as you continue clicking the block, the cat gets blurrier as it grows, eventually becoming crisp again if you click the block enough

Operating System and Browser

All

@kchadha
Copy link
Contributor

kchadha commented Jun 4, 2020

@cwillisf @fsih @adroitwhiz, assigned this to you for discussion (and then documenting here)

@adroitwhiz
Copy link
Contributor Author

The fix itself is quite easy to implement-- I already have it up in a branch:
https://adroitwhiz.github.io/scratch-gui/no-vector-blur/

The hard part is benchmarking across devices to make sure the increased RAM usage is acceptable (and figuring out what "acceptable" means).

@tutacat
Copy link

tutacat commented Jun 17, 2020

@adroitwhiz Have you also looked at why the vector sprites have odd cropping?
(e.g. a single straight won't display, and a single line sometimes gets chopped somewhere)

@apple502j
Copy link

@adroitwhiz
Copy link
Contributor Author

adroitwhiz commented Jun 17, 2020

@tutacat If you're talking about #639 or #427, that'll be fixed by #594

@fsih
Copy link
Contributor

fsih commented Jun 22, 2020

Discussion:

  • It's very difficult to instrument the VRAM usage of graphics cards, so we probably wouldn't be able to do that
  • We can use the built-in profiler on browsers to look at the total RAM usage and compare before and after
  • We have a maximum texture size in the renderer that we wouldn't go above, so this wouldn't affect very large textures, only the average size of textures
  • We recommend testing a relatively complex project with a large number of vector sprites and comparing RAM usage before and after the change on a very low-end device (probably the raspberry pi), and seeing if the change causes performance (frame rate) to become unacceptable.
  • We think it's worth putting in if the performance is acceptable

@fsih
Copy link
Contributor

fsih commented Jun 22, 2020

Next steps

@adroitwhiz do you have the PR for https://adroitwhiz.github.io/scratch-gui/no-vector-blur/ up somewhere for us to look at?

@BryceLTaylor could you run a project with a lot of vector sprites on a Raspberry Pi and compare if it's noticeably worse on https://adroitwhiz.github.io/scratch-gui/no-vector-blur/ vs prod?

@adroitwhiz
Copy link
Contributor Author

Just created a PR for this change: #649

@BryceLTaylor
Copy link

I tested the branch on a Raspberry Pi 4 by playing a MAP (https://scratch.mit.edu/projects/398958757/). On production after 20 or so seconds of playing the project the whole computer became unresponsive. The mouse cursor moved several seconds after I had tried moving it, and then eventually stopped moving altogether. I had to restart the whole machine.
On the branch it played fine for ~2 minutes, but eventually the tab crashed.

Also, on a project with just the default cat I saw some somewhat strange behavior when sprites were at 117% and 118% size, but I have been unable to reproduce it. The cat does look a little less blurry to me than with a similar project on production.

@BryceLTaylor BryceLTaylor removed their assignment Jul 14, 2020
@fsih fsih closed this as completed in #649 Aug 4, 2020
@mitnerd
Copy link

mitnerd commented Oct 30, 2020

This bug is linked to this fix but it's still not fixed. Can 5886 be reopened?
scratchfoundation/scratch-gui#5886

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment