Weird texture artifacts around borders of small sprites
creikey opened this issue · 3 comments
creikey commented
edubart commented
Could be an issue in how you are using Sokol, or in Sokol, or in the backend, or in graphics card driver, or in the graphics hardware. Most likely to be an issue in how you are using Sokol.
Try:
- Using
SG_WRAP_CLAMP_TO_EDGE
wrap mode when loading texture. Looks like in the screenshot that the texture is being loaded withSG_WRAP_REPEAT
instead, probably changing that will fix. - If you are using a texture atlas, make sure to add transparent gap between all sprites.
- Update your graphics driver.
- Try other graphics backend or hardware.
creikey commented
Ah yeah in that screenshot it's got WRAP_REPEAT, I switched it to load with SG_WRAP_CLAMP_TO_EDGE and still saw the artifacts in some cases. I'm drawing the sprite with this fragment shader:
@fs fs
uniform sampler2D iChannel0;
uniform fs_params {
vec4 iColor;
};
in vec2 texUV;
out vec4 fragColor;
vec4 texture2DAA(sampler2D tex, vec2 uv) {
vec2 texsize = vec2(textureSize(tex,0));
vec2 uv_texspace = uv*texsize;
vec2 seam = floor(uv_texspace+.5);
uv_texspace = (uv_texspace-seam)/fwidth(uv_texspace)+seam;
uv_texspace = clamp(uv_texspace, seam-.5, seam+.5);
return texture(tex, uv_texspace/texsize);
}
void main() {
fragColor = texture2DAA(iChannel0, texUV) * iColor;
}
@end
Thanks for making this library by the way! It's been working great so far
edubart commented
As the issue cannot be related to Sokol GP, I am closing this. I've already gave you a direction, you should find the solution by yourself.