Fix MIPMaps being disabled for compressed textures.

This commit is contained in:
Ben Richards 2024-02-20 13:02:19 +13:00
parent 1f8276ac76
commit a2178c8466
3 changed files with 10 additions and 9 deletions

View file

@ -70,8 +70,9 @@ The Phaser Input and related classes have been updated to be more consistent wit
* When a `Layer` Game Object is destroyed, i.e. from changing or restarting a Scene, it will no longer cause an error when trying to destroy the children on its display list. Fix #6675 (thanks @crockergd @gm0nk)
* `DynamicTexture` will now automatically call `setSize(width, height)` for both WebGL and Canvas. Previously it only did it for WebGL. This fixes an issue where DynamicTextures in Canvas mode would have a width and height of -1. Fix #6682 (thanks @samme)
* `DynamicTexture.setSize` will now check to see if the `glTexture` bound to the current frame is stale, and if so, destroy it before binding the one from the Render Target. This fixes an issue where constantly destroying and creating Dynamic Textures would cause a memory leak in WebGL. Fix #6669 (thanks @DavidTalevski)
* Fix MIPmap filters being effectively disabled for compressed textures.
* `WebGLRenderer.getCompressedTextures` can now identify BPTC and RGTC support correctly. These were previously skipped.
* PVR compressed texture files now support sRGB color space in S3TCSRGB, ETC, and ASTC formats. (Thanks @dominikhalvonik)
* PVR compressed texture files now support sRGB color space in S3TCSRGB, ETC, and ASTC formats. Fix #6247 (thanks @dominikhalvonik)
* Compressed texture files which are incompatible with WebGL will now fail to load, and display a console warning explaining why. Previously they might seem to load, but not display properly.
* Add experimental support for BPTC compressed textures in PVR files.
* Change `S3TCRGB` to `S3TCSRGB` in `WebGLTextureCompression`, `CompressedTextureFileConfig`, and `FileConfig` typedefs.

View file

@ -2066,14 +2066,14 @@ var WebGLRenderer = new Class({
if (scaleMode === CONST.ScaleModes.LINEAR && this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
var isCompressed = source && source.compressed;
var isMip = pow || (isCompressed && source.mipmaps.length > 1);
if (source && source.compressed)
{
// If you don't set minFilter to LINEAR then the compressed textures don't work!
minFilter = gl.LINEAR;
// Filters above LINEAR only work with MIPmaps.
// These are only generated for power of two (POT) textures.
// Compressed textures with mipmaps are always POT,
// but POT compressed textures might not have mipmaps.
minFilter = (this.mipmapFilter && isMip) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}

View file

@ -244,7 +244,7 @@ var TextureSource = new Class({
}
else if (this.compressionAlgorithm)
{
this.glTexture = renderer.createTextureFromSource(source);
this.glTexture = renderer.createTextureFromSource(source, undefined, undefined, scaleMode);
}
else if (source instanceof Uint8Array)
{