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

Improved sprite filtering #3021

Open
ghost opened this issue Oct 25, 2021 · 0 comments
Open

Improved sprite filtering #3021

ghost opened this issue Oct 25, 2021 · 0 comments
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible

Comments

@ghost
Copy link

ghost commented Oct 25, 2021

What problem does this solve or what need does it fill?

I've made a new shader for bevy_sprite that improves texture filtering.
This improves:

  • jitter/distortion when scaling
  • aliased edges when rotating
  • fixes the edge bleeding present in texture atlases

I'm changing the texture sampler manually, but how do I change the default texture sampler for sprites/ColorMaterial? I need to set mag_filter to linear, but this is difficult to do because samplers are tied to textures.

What solution would you like?

Textures and samplers should be decoupled. While textures are only useful when paired with a sampler, this assumes that entities sharing the same texture also want to share the same sampler.
This also allows for sampler reuse (#5), when a sampler isn't present we can use the default default sampler.

What alternative(s) have you considered?

The demo below uses a system to modify sprite entity textures when they are created. However, this is not ideal because entities have different textures. Two copies of the same texture and texture atlas assets are required just to change their sampler!

Additional context

Demo for texture atlas scaling. (my implementation is on the left)

scale-demo.mp4

Sprite rotation aliasing:

02

@ghost ghost added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Oct 25, 2021
@NiklasEi NiklasEi added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Feature A new feature, making something new possible
Projects
None yet
Development

No branches or pull requests

1 participant