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 edge-of-cell artifacts in WebGL #276

Open
BenjaminDRichards opened this issue Jul 21, 2016 · 0 comments
Open

Investigate edge-of-cell artifacts in WebGL #276

BenjaminDRichards opened this issue Jul 21, 2016 · 0 comments
Labels

Comments

@BenjaminDRichards
Copy link
Contributor

Under certain circumstances, sampling from a texture atlas cell will sample the neighbouring cell, causing a distinctive fuzzy line on the very edge of the sprite.

This is caused when the neighbouring cell has data in the outermost row/column of pixels. When the shader samples a texel with non-integer coordinates, it can interpolate partially into that data. Non-integer texel coordinates occur when the game object is scaled, rotated, or moved to non-integer coordinates.

The contributing factors are both common:

  • Cells without gutters (1-pixel empty margins are difficult to create with TextureAtlas JSON, and potentially impossible with SpriteSheet objects)
  • Free movement of assets/cameras

There are solutions, but they're not optimal:

  • Add gutters to all assets (this may introduce transparent glitches into tiling surfaces)
  • Lock transforms to integer translation and scale and right-angle rotations only (potentially jagged)
  • Use NEAREST texture interpolation instead of LINEAR (this doesn't necessarily work, either)

I've tried messing about with the shaders, but it's not great. It turns out that texel coordinates don't give up interpolation without a fight.

This merits documentation and further investigation.

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

1 participant