gamelab / kiwi.js

Kiwi.js is a blazingly fast mobile & desktop browser based HTML5 game framework. It uses CocoonJS for publishing to the AppStore.
www.kiwijs.org
MIT License
1.41k stars 194 forks source link

Investigate edge-of-cell artifacts in WebGL #276

Open BenjaminDRichards opened 8 years ago

BenjaminDRichards commented 8 years ago

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:

There are solutions, but they're not optimal:

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.