benjaminhon
We don’t do anything special with setFilters
; we simply set Pixi constants and invoke Pixi functions to generate mipmaps when needed because we use the Pixi WebGL renderer. Here's the code:
public setFilters (minFilter: TextureFilter, magFilter: TextureFilter): void {
const style = this.texture.source.style;
style.minFilter = SpineTexture.toPixiTextureFilter(minFilter);
style.magFilter = SpineTexture.toPixiTextureFilter(magFilter);
this.texture.source.autoGenerateMipmaps = SpineTexture.toPixiMipMap(minFilter);
this.texture.source.updateMipmaps();
}
Here, we have SpineTexture.toPixiTextureFilter
:
private static toPixiTextureFilter (filter: TextureFilter): SCALE_MODE {
switch (filter) {
case TextureFilter.Nearest:
case TextureFilter.MipMapNearestLinear:
case TextureFilter.MipMapNearestNearest:
return 'nearest';
case TextureFilter.Linear:
case TextureFilter.MipMapLinearLinear: // TextureFilter.MipMapLinearLinear == TextureFilter.MipMap
case TextureFilter.MipMapLinearNearest:
return 'linear';
default:
throw new Error(`Unknown texture filter: ${String(filter)}`);
}
}
And finally:
private static toPixiMipMap (filter: TextureFilter): boolean {
switch (filter) {
case TextureFilter.Nearest:
case TextureFilter.Linear:
return false;
case TextureFilter.MipMapNearestLinear:
case TextureFilter.MipMapNearestNearest:
case TextureFilter.MipMapLinearLinear: // TextureFilter.MipMapLinearLinear == TextureFilter.MipMap
case TextureFilter.MipMapLinearNearest:
return true;
default:
throw new Error(`Unknown texture filter: ${String(filter)}`);
}
}
As you can see, if you set minFilter
to:
Nearest
or Linear
, you get the respective filter (nearest or linear) without mipmaps.
MipMapNearest*
, you get the Nearest filter with mipmaps.
MipMapLinear*
, you get the Linear filter with mipmaps.
That's it. Once these settings are applied, we invoke source.updateMipmaps
, and the mipmaps will be updated accordingly.
Have you tried doing the same thing without the Spine GameObject layer? Try rendering the texture using a Sprite, setting the filters and mipmaps as desired. Once you're satisfied, use the same settings for the textures of the Spine GameObject.
Please try this and report back if the results you get with the Sprite differ from those with the Spine GameObject when using the same texture filter/mipmap configuration.