CreateJS / EaselJS

The Easel Javascript library provides a full, hierarchical display list, a core interaction model, and helper classes to make working with the HTML5 Canvas element much easier.
http://createjs.com/
MIT License
8.13k stars 1.97k forks source link

proposal: allow linear texture filtering when antialias is off #998

Closed Nestorferrando closed 5 years ago

Nestorferrando commented 5 years ago

Now, StageGL only does linear texture filtering if antialias is activated.

On some devices, antialias can cause relevant performance drops, but disabling it now reduces a lot the graphic quality because texture filtering is also changed to nearest, even in POT textures.

If possible, would it be possible to keep enabled linear filtering for POT, even if antialias is disabled?

thanks

original related code:

p.setTextureParams = function (gl, isPOT) {
    if (isPOT && this._antialias) {
        //non POT linear works in some devices, but performance is NOT good, investigate
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
    } else {
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
    }
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
};
DavidHGillen commented 5 years ago

For now just override the function with one that follows your specification. So long as you do it before displaying/caching any content it'll affect everything that matters.

The support and performance matrix of what devices do what well in what situations was more complex then I was willing to support. This means it's impossible to define a meaningful default behavior for sample filtering. This would cause more flags and configuration options than we could support and my best advice would be "test it I guess". That's not helpful to anyone.

This was basically intended as a gate to "smooth images" or "not smooth images" with appropriate performance warnings. In part I was also hoping that WebGL 2.0 would hurry up its adoption rates so I could ditch that check all together, it removes some complications to sample filtering, but it seems to be going slowly thanks to low powered GPUs in mobile devices still being so common.

The wonderful (and worst) thing about JavaScript is the ability to change what you like about everyone's code. So for now I recommend just replacing that function on the StageGL prototype after you load it. I won't be changing it anytime soon unfortunately. Even if it was on the slate there's other assumptions I need to double check like "do I want/can I make a good API for per texture settings", so the change might not even be specifically this.

Closing this for now, thanks!